package com.xyzk.diagnose.activity;
import static com.xyzk.diagnose.tools.Common.FLASH_MODULE_LIST;
import static com.xyzk.diagnose.tools.WifiAdmin.TAG;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.TimeUnit;

import org.ini4j.Ini;
import org.ini4j.InvalidFileFormatException;
import org.ini4j.Profile;
import org.ini4j.Profile.Section;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.xyzk.diagnose.R;
import com.xyzk.diagnose.TApplication;
import com.xyzk.diagnose.activity.bluetooth.BluetoothService;
import com.xyzk.diagnose.entity.Can;
import com.xyzk.diagnose.entity.Cartype;
import com.xyzk.diagnose.httputils.HttpRequest;
import com.xyzk.diagnose.httputils.ServerSocket;
import com.xyzk.diagnose.tools.Common;
import com.xyzk.diagnose.tools.CommonXml;
import com.xyzk.diagnose.tools.Commonfunc;
import com.xyzk.diagnose.tools.Communication;
import com.xyzk.diagnose.tools.DbAdapter;
import com.xyzk.diagnose.tools.DbAdapter.TableData;
import com.xyzk.diagnose.tools.DbAdapter.TableMain;
import com.xyzk.diagnose.tools.FileReader;
import com.xyzk.diagnose.tools.JCommunication;
import com.xyzk.diagnose.tools.Security;
import com.xyzk.diagnose.entity.EcuModule;

import android.annotation.SuppressLint;
import android.content.ContentValues;
import android.content.Context;
import android.content.IntentFilter;
import android.os.Handler;
import android.util.Log;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

public class DiagnoseThread extends Thread{

	private ArrayList<Map<String, String>> allDatas = new ArrayList<Map<String,String>>();
	private BluetoothService bluetooth = BluetoothService.getInstance();
	private JCommunication Jcom = JCommunication.getInstance();
	private ArrayList<String> mPrint = new ArrayList<String>();
	private ArrayList<String> mDtc = new ArrayList<String>();
	private ArrayList<String> t_print = new ArrayList<String>();
	private List<EcuModule> ecumodules = new ArrayList<EcuModule>();
	EcuModule ecuModule = null;
	private Cartype cartype = Cartype.getInstance();
	private byte [] keep = {0x02, 0x3E, (byte) 0x80};
	private byte [] readbuf = new byte[256];
	private byte [] seed = new byte[8];
	private byte [] key = new byte[8];
	private Handler mHandler;
	private String module;
	private String stepType;
	private String stepName;
	private boolean isOk;	//模块检测结果
	private boolean uploadPC;//是否上传到PC
	private boolean uploadMes;//是否上传到MES
	public boolean exit;
	private int stepId = 100;
	private int error = 5000;

	private int key_num = 0;
	public int num;
	boolean m_upfile_isok = false;
	Communication m_com = Communication.getInstance();
	int [] canid = new int[2];//   记录canid变化
	boolean  t_isok = true;


	/**
	 * @param module 检测模块的位置
	 * @param mHandler message处理对象
	 */
	public DiagnoseThread(String module, Handler mHandler) {
		this.module = module;
		this.mHandler = mHandler;
	}

	/**
	 * 设置退出
	 */
	public void setExit(boolean exit){
		this.exit = exit;
		bluetooth.exit = exit;
	}

	@Override
	public void run()
	{
		if(Common.Communication==0){
			if(!getBoxInfo()){//连接接头
				showTip(R.string.func_show_tip1) ;
				return;
			}
		}else {
			String ver = m_com.ReadBoxVersion();
			if(ver.length() > 4) //ok
			{
				Common.obdSerialNum= ver.substring(0,12);
				String app = ver.substring(ver.length() - 4);
				showTip("Box序列号:" + Common.obdSerialNum +"\nBox版本号:V" + app);
			}
			else
			{
				showTip("通讯盒初始化失败,请检查车辆是否已经连接!") ;
				return;
			}
		}
//		if(Common.stationPos == 3) //刷写   //todo 修改兼容
//		{
//			String ver = m_com.ReadBoxVersion();
//			if(ver.length() > 4) //ok
//			{
//				Common.obdSerialNum= ver.substring(0,12);
//				String app = ver.substring(ver.length() - 4);
//				showTip("Box序列号:" + Common.obdSerialNum +"\nBox版本号:V" + app);
//			}
//			else
//			{
//				showTip("通讯盒初始化失败,请检查车辆是否已经连接!") ;
//				return;
//			}
//		}
//		else
//		{
//			if(!getBoxInfo()){//连接接头
//				showTip(R.string.func_show_tip1) ;
//				return;
//			}
//		}
		if(cartype.getMap("AUTO") > 0)
		{//所有模块、
			cartype.start_time = Commonfunc.getDateTime();  //当前时间
			exeAllModule();
			cartype.end_time =Commonfunc.getDateTime();  //当前时间
			showTip(R.string.func_show_saveresult);
			//存储结果
			if(ecumodules.size() > 0)
			{
				cartype.result = 1;
				for(EcuModule mod : ecumodules)
				{
					if(mod.getresult() > 1)
					{
						cartype.result = mod.getresult();
						break;
					}
				}
			}
			if(exit) return;//TODO
		}
		else
		{//单个模块或者诊断仪检测
			stepId = 100;
			if(cartype.getMap(module) > 0)
				exeSingleModule(module + cartype.getMap(module));
			else
				exeSingleModule(module);
			showTip(R.string.func_show_saveresult);//根据这条指令判断是否检测完，不是下面那个检测完成
		}
		if(exit) return;//TODO
		Commonfunc.sleep(1000);
		SendDataToDbAndPrint(cartype.getStationsList().get(Common.stationPos),Common.printNum);
		showTip("检测完成, " + (cartype.result == 2 ? "不合格" : "合格"));
	}


	/**
	 * 获取字符串
	 * @param resId 资源id
	 * @return 字符串
	 */
	private String getString(int resId){
		return TApplication.getContext().getString(resId);
	}

	/**
	 * 显示提示信息
	 * @param resId 资源ID
	 */
	private void showTip(int resId){
		if(!exit){
			handlerMessage(Common.TEXTVIEW_SHOW_TIP, resId);
		}

	}

	/**
	 * 显示提示信息
	 * @param text 显示内容
	 */
	private void showTip(String text){
		if(!exit) {
			handlerMessage(Common.TEXTVIEW_SHOW_TIP, text);
		}
	}

	/**
	 * 处理消息
	 * @param what 消息标志
	 * @param text 显示内容资源ID
	 * @param time 可传可不传 显示时间
	 */
	private void handlerMessage(int what, int text, int... time){
		if(!exit){
			handlerMessage(what, getString(text), time);
		}
	}

	/**
	 * 处理消息
	 * @param what 消息标志
	 * @param text 显示内容字符串
	 * @param time 可传可不传 显示时间
	 */
	private void handlerMessage(int what, String text, int... time){
		if(!exit)
		if(time.length == 0){
			mHandler.obtainMessage(what, text).sendToTarget();
		}else if(time.length == 1){
			mHandler.obtainMessage(what, time[0], 0, text).sendToTarget();
		}else{
			mHandler.obtainMessage(what, time[0], time[1], text).sendToTarget();
		}
	}


	/**
	 * 获取蓝牙OBD信息
	 * @return false表示不能和蓝牙正常通信
	 */
	private boolean getBoxInfo(){
		byte[] serialNum = new byte[12];
		byte[] softVer = new byte[2];
		for(int i = 0; i < Common.CMD_REQUEST; i ++){
			if(bluetooth.getObdSerialNum(serialNum, softVer)) break;
			if(i == Common.CMD_REQUEST - 1) return false;
		}
		Common.obdSerialNum = new String(serialNum);
		String content = "Box序列号:" + Common.obdSerialNum +
				"\nBox版本号:" + softVer[0] + "." + Commonfunc.byteToString(softVer[1]);
		showTip(content);
		Commonfunc.sleep(500);
		return true;
	}

	/**
	 * 执行所有module
	 */
	private void exeAllModule(){
		ArrayList<String> modules = cartype.getModuleList();
		for(int i = 0; i < modules.size(); i ++){
			if(exit) return;
			String stepName = modules.get(i);
			if(stepName.contains(Common.SHW)){
				handlerSHW(stepName, false);
			}else{//OPT REQ
				mHandler.sendEmptyMessage(Common.FLASH_MODULE_LIST);
				ecuModule = new EcuModule(stepName);
				if(cartype.getMap(stepName) > 0){
					exeSingleModule(stepName + cartype.getMap(stepName));
				}
				else
					exeSingleModule(stepName);
				ecumodules.add(ecuModule);
			}
		}
	}

	/**
	 * 执行单个模块
	 * @param modeName 模块名称
	 */
	public void exeSingleModule(String modeName){
		isOk = true;
		String path = cartype.carDirectory + "step_" + Common.stationPos + ".ini";
		if(Common.stationPos == 3 && (cartype.car.indexOf("62") > 0 || cartype.car.indexOf("63") > 0))
			path = cartype.flashDirectory + "step_" + Common.stationPos + ".ini";
		Section sec = FileReader.readSectionForIni(path, modeName);
		if(sec == null) return;
		num = Integer.valueOf(sec.get("NUM"));
		stepName = sec.get(Common.MODULE_NAME);
		showProcessList(Common.NULL,Common.NULL, Common.NULL);
		showTip(R.string.func_show_tip_dianoseing);

		exeFunctionModule(modeName, sec);

		mPrint.add(modeName + Common.NULL + (isOk ? Common.OK : Common.NG));

		if(modeName.equals("PEPS1")){
			mPrint.add("钥匙数量: " + key_num + " 把");
			//ecuModule.addcontext("钥匙数量: " + key_num + " 把");
			mPrint.add("PIN码: " + Commonfunc.bytesToHexString(cartype.pin, 0, cartype.pin.length));
			ecuModule.addcontext("PIN码: " + Commonfunc.bytesToHexString(cartype.pin, 0, cartype.pin.length));
		}
		if(mDtc.size() > 0)
		{
			for(int i = 0; i < mDtc.size(); i++){
				mPrint.add(mDtc.get(i));
			}
		}
		if(t_print.size() > 0)
		{
			for(int i = 0; i < t_print.size(); i++){
				mPrint.add(t_print.get(i));
			}
		}
	}

	/**
	 * 显示检测进程数据列表
	 * @param content 内容
	 * @param result 结果
	 */
	@SuppressLint("SuspiciousIndentation")
	public void showProcessList(String content, String ctand, String result){
		HashMap<String, String> map = new HashMap<String, String>();
		String xtr=new String();
		map.put(Common.ID, String.valueOf(stepId++));
		map.put(Common.TESTNAME, stepName);
		map.put(Common.CONTENT, content);
		map.put(Common.CTAND,ctand);
		map.put(Common.RESULT, result);
		if (ctand.equals("环境温度")){
			stepName = ctand;
			ctand=Common.NULL;
			map.put(Common.TESTNAME, stepName);
			map.put(Common.CTAND,ctand);
		}
		if(Common.NG.equals(result)){
			isOk = false;
			cartype.result = 2;//检测结果不合格
			if(ecuModule != null)
			{
				if(ecuModule.getresult() < 2)
					ecuModule.setresult(2);
				//添加内容
				if((stepName.indexOf("零件号") >= 0) || (stepName.indexOf("供应商代码") >= 0) || (stepName.indexOf("硬件版本") >= 0) || (stepName.indexOf("软件版本") >= 0) || (stepName.indexOf("序列号") >= 0) || (stepName.indexOf("配置码") >= 0))
				{
					if (ctand.equals(Common.NULL)){
						xtr = stepName + ":失败[" + content + "]";
					}else xtr = stepName + ":失败[" + content + "]参考值["+ctand+"]";
					ecuModule.addcontext(xtr);
				}
				else
				if (ctand.equals(Common.NULL)){
					xtr = stepName + ":失败[" + content + "]";
				}else xtr = stepName + ":失败[" + content + "]参考值["+ctand+"]";
				ecuModule.addcontext(xtr);
			}

		}
		else if(Common.OK.equals(result))
		{
			if(ecuModule != null)
			{
				if(ecuModule.getresult() < 1)
					ecuModule.setresult(1);
				if(stepName.indexOf("温度")>=0){
					if (ctand.equals(Common.NULL)){
						xtr = stepName + ":" + content + "";
					}else xtr = stepName + ":" + content + "参考值["+ctand+"]";
					ecuModule.addcontext(xtr);
				}
			}
		}else if (Common.NULL.equals(result)) {
			if (ecuModule != null){
				if (ecuModule.getresult() < 1)
					ecuModule.setresult(1);
				if (stepName != null && stepName.indexOf("温度") >= 0) {
					if (ctand.equals(Common.NULL)) {
						xtr = stepName + ":" + content + "";
					} else xtr = stepName + ":" + content + "参考值[" + ctand + "]";
					ecuModule.addcontext(xtr);
				}
			}
		}
		if(!exit)
		mHandler.obtainMessage(Common.FLASH_DATA_LIST, map).sendToTarget();
	}
	/**
	 * 处理SHW
	 * @param keepCommuit 是否需要发送3E 00
	 */
	public void handlerSHW(String type, boolean keepCommuit){
		handlerSHW(type, "", keepCommuit);
	}

	/**
	 * 处理SHW
	 * @param keepCommuit 是否需要发送3E 00
	 */
	public void handlerSHW(String type, String name, boolean keepCommuit){
		int index1 = type.indexOf("<");
		int index2 = type.indexOf(">");
		String mode = type.substring(4, index1);
		int time = Integer.valueOf(type.substring(index1 + 1, index2));
		if(Common.ON.equals(mode)){
			handlerMessage(Common.DIALOG_SHOW_TEXT, R.string.msg_show_keyon, time);
		}else if(Common.OFF.equals(mode)){
			handlerMessage(Common.DIALOG_SHOW_TEXT, R.string.msg_show_keyoff, time);
		}else{
			handlerMessage(Common.DIALOG_SHOW_TEXT, name, time);
		}
		Common.wait = true;
		if(keepCommuit){
			while(Common.wait){
//				bluetooth.canSendAndRecvN2N(keep, new byte[128], Common.CMD_MAX_TIME);
				error = m_com.CanSendOneOnly(canid[0],keep,keep.length);
				Commonfunc.sleep(Common.CMD_MAX_TIME);
			};
		}else{
			while(Common.wait){
				Commonfunc.sleep(Common.DIALOG_WAIT_TIME);
			};
		}
	}

	/**
	 * 赋值所有详细数据
	 * @param allDatas 所有详细数据
	 */
	public void setAllShowDatas(List<ArrayList<Map<String, String>>> allDatas){
		for(int i = 0; i < allDatas.size(); i++){
			this.allDatas.addAll(allDatas.get(i));
		}
	}

	//	/**
//	 * 上传数据到上位机并打印结果
//	 */
//	private void sendDataToDbAndPrint(){
//		ArrayList<String> list = new ArrayList<String>();
//		list.add(new String(cartype.vin));
//		list.add(cartype.config);//配置码
//		list.add(cartype.getStationsList().get(Common.stationPos));//工位
//		list.add(cartype.car);//4车型名
//		list.add(cartype.cartype == null ? cartype.car : cartype.cartype);//5 车型配置
//		list.add(Commonfunc.getDateTime());//6 日期
//		list.add(Common.obdSerialNum);  //7 诊断仪序列号
//		list.add(Common.printPinNum + "");//8打印密码本
//		list.add(Commonfunc.bytesToHexStringSpace(cartype.pin, 0, cartype.pin.length));
//		list.add(Common.printNum + ""); //10 结果打印机序号
//		list.add(cartype.result + ""); 		//11 测试结果
//		list.add("null"); //TBOX
//
//		String result="1:" + list.toString() + "," + mPrint.toString();
//		ServerSocket server = new ServerSocket();
//		for(int i = 1; i < 4; i ++){
//			if(server.connectServer(Common.serverIP, Common.serverPort)){
//				showTip("正在连接服务器" + i + "次...");
//				//上传主表并打印
//				uploadPC = server.sendDataToServer(Commonfunc.getByteLenOfFive(result));
//				Commonfunc.sleep(500);
//				//上传详细数据
//				//String ups = "5:" + allDatas.size() + ":" + new String(cartype.vin) + ";" + allDatas.toString();
//				//boolean detail = server.sendDataToServer(Commonfunc.getByteLenOfFive(ups));
//				//bluetooth.mLog.printMessage("result:" + detail );
//				String updata = "5:" + allDatas.size() + ":" + new String(cartype.vin) +";" + new String(allDatas.toString());
//				server.sendDataToServer(Commonfunc.getByteLenOfFive(updata));
//
//				//上传log文件
//				Commonfunc.sleep(700);
//				showTip("正在上传日志...");
//				//UploadLogfiletoServer(server);
//				//String logFile = "L:" + Common.obdSerialNum + "," + bluetooth.mLog.fileName + ",[" + bluetooth.mLog.readLogFile() + "]";
//				//server.sendDataToServer(Commonfunc.getByteLenOfFive(logFile));
//				//bluetooth.mLog.printMessage("\n" + Commonfunc.getByteLenOfFive(logFile));
//				if(UploadLogfiletoServer(server) == true)
//					showTip("上传日志成功！");
//				else
//					showTip("上传日志失败！");
//
//				server.close();
//				break;
//			}
//		}
//		//数据存到本地
////		saveDataToNativeDb(result, allDatas);
//	}
	// 上传数据至web服务器
	private boolean SendDataToDbAndPrint(String Pname,int Printnum)
	{
		m_com.m_log.PrintLog("Start Update Data");
		ArrayList<String> list = new ArrayList<String>();
		list.add(new String(cartype.vin));
		list.add(Commonfunc.bytesToHexString(cartype.byteConfig,0,cartype.byteConfig.length));//配置码
		list.add(Pname);//工位
		list.add(cartype.name);//车型
		list.add(cartype.name);//打印单据中的name
		list.add(cartype.date);
		list.add(Common.obdSerialNum);
		//增加的这里打印密码本
		list.add(Common.PrintPinnum + "");
		//增加的这里打印PIN码
		list.add(Commonfunc.bytesToHexStringP(cartype.pin, 0, 4));
		//打印结果
		list.add(Printnum + "");
		list.add(cartype.result + "");
		list.add("null");
		list.add("0");
		list.add("null");
		String v_print = "";
		m_com.m_log.PrintLog("Start Update Data2");
		//上传web服务器
		if(Common.web_enable  == true)
		{
			JSONObject jsonmain = new JSONObject();
			try {
				jsonmain.put("resultVin", new String(cartype.vin));
				jsonmain.put("resultCar",cartype.car);
				jsonmain.put("resultCartype", cartype.cartype);
				jsonmain.put("resultStation",Pname);
				jsonmain.put("resultCarname",cartype.name);
				//jsonmain.put("resultCardate",Common.cartype.date);
				jsonmain.put("resultCardate",cartype.start_time);
				jsonmain.put("resultCartime",cartype.start_time);
				jsonmain.put("resultDevice",Common.obdSerialNum);
				//打印机编号做返修不打印的特殊处理
				if(cartype.OptMode == 0) {
					jsonmain.put("resultPrintnum",""+ Common.printNum);
				}else {
					jsonmain.put("resultPrintnum","99");
				}
				jsonmain.put("resultTestnum", "1");
				if(cartype.result <= 1)
					jsonmain.put("resultResult","OK");
				else
					jsonmain.put("resultResult","NG");
				//int v_size = modules.size();
				for(EcuModule mod : ecumodules)
				{
					v_print += mod.toString();
				}
//				System.out.println(v_print);
				jsonmain.put("resultPrint",v_print);
				jsonmain.put("resultPin",Commonfunc.bytesToHexStringP(cartype.pin, 0, 4));
				jsonmain.put("resultEsk",Commonfunc.bytesToHexStringP(cartype.esk, 0, 16));
				jsonmain.put("resultColor","");
				jsonmain.put("resultAppver",getString(R.string.Version));
				jsonmain.put("resultUp2mes","0");
				jsonmain.put("resultUser","test");
				jsonmain.put("fileName",m_com.m_log.getFileName());
				jsonmain.put("resultLog","");
				JSONArray array=new JSONArray();
				for(int k = 0; k < allDatas.size(); k ++)
				{
					JSONObject jsondetail = new JSONObject();
					jsondetail.put("mVin",new String(cartype.vin));
					jsondetail.put("mTestcode",allDatas.get(k).get("SHOW_ID"));
					jsondetail.put("mContext",allDatas.get(k).get("SHOW_CONTEXT"));
					jsondetail.put("mTestdata",allDatas.get(k).get("SHOW_RESULT"));
					jsondetail.put("mStand",allDatas.get(k).get("SHOW_CTAND"));
					jsondetail.put("mResult",allDatas.get(k).get("SHOW_TIME"));
					array.put(k,jsondetail);
				}
				jsonmain.put("tableResultDetails", array);
				Long v_upfileid = (long) 0;

				// 上传
				m_com.m_log.PrintLog("UpAddr:"+ Common.web_updata);
				System.out.println(jsonmain);
				m_com.m_log.PrintLog(v_print);
				String res = HttpRequest.sendPostToMyMes(Common.web_updata, jsonmain.toString().replace(">",""));
				m_com.m_log.PrintLog(res);
				if(res.indexOf("200") > 0) //ok
				{
					JSONObject resjson = new JSONObject(res);
					JSONObject son = resjson.getJSONObject("data");
					if(son != null)
						v_upfileid = son.getLong("resultId");
					showTip("上传服务器数据成功");
					Common.updata_isok = true;
				}else {
					Common.updata_isok=false;
				}
				//  添加提示，数据暂时无法上传
				if (Common.updata_isok==false&&!exit){
					Object tishi = "数据暂时无法上传";
					mHandler.obtainMessage(Common.DIALOG_SHOW_YES_NO, 0, 0,tishi).sendToTarget();
				}
				//上传日志文件
				if(v_upfileid > 0)
				{
					showTip("上传日志文件...");
					m_com.m_log.PrintAppend("UpFile:"+ Common.web_API_File);
					if(uploadFiles(Common.web_API_File,m_com.m_log.getFilePath(),v_upfileid) == true)
						showTip("上传日志文件成功");
					else
						showTip("上传日志文件失败");
				}
			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		else
		{
			String result="1:" + list.toString() + "," + mPrint.toString();
			ServerSocket server = new ServerSocket();
			for(int i = 1; i < 4; i ++){
				if(server.connectServer(Common.serverIP, Common.serverPort)){
					showTip("正在连接服务器" + i + "次...");
					//上传主表并打印
					uploadPC = server.sendDataToServer(Commonfunc.getByteLenOfFive(result));
					Commonfunc.sleep(500);
					//上传详细数据
					//String ups = "5:" + allDatas.size() + ":" + new String(cartype.vin) + ";" + allDatas.toString();
					//boolean detail = server.sendDataToServer(Commonfunc.getByteLenOfFive(ups));
					//bluetooth.mLog.printMessage("result:" + detail );
					String updata = "5:" + allDatas.size() + ":" + new String(cartype.vin) +";" + new String(allDatas.toString());
					server.sendDataToServer(Commonfunc.getByteLenOfFive(updata));

					//上传log文件
					//Commonfunc.sleep(700);
					//showTip("正在上传日志...");
					//UploadLogfiletoServer(server);
					//String logFile = "L:" + Common.obdSerialNum + "," + bluetooth.mLog.fileName + ",[" + bluetooth.mLog.readLogFile() + "]";
					//server.sendDataToServer(Commonfunc.getByteLenOfFive(logFile));
					//bluetooth.mLog.printMessage("\n" + Commonfunc.getByteLenOfFive(logFile));
					//if(UploadLogfiletoServer(server) == true)
					//	showTip("上传日志成功！");
					//else
					//	showTip("上传日志失败！");

					server.close();
					break;
				}
			}
		}
		//保存数据到本地
		SaveDataToDb("1:" + list.toString() + "," + v_print,allDatas,Pname);
		return true;
	}
	// 保存数据到本地数据库
	void SaveDataToDb(String printdata,ArrayList<Map<String, String>> list,String Pname)
	{
		DbAdapter db = new DbAdapter();
		//---------------------第一步存主数据库---------------------
		db.open();
		//查询测试次数
		int oldtestnum = db.QueryMainTestNum(new String(cartype.vin));
		if(Common.Debug) Log.i(TAG,"已经存储次数为:" + oldtestnum);
		ContentValues cv = new ContentValues();
		cv.put(TableMain.vin, new String(cartype.vin));
		cv.put(TableMain.car,cartype.car);
		cv.put(TableMain.cartype, cartype.cartype);
		cv.put(TableMain.carname, cartype.name);
		cv.put(TableMain.carstation,Pname);
		cv.put(TableMain.device, Common.obdSerialNum);
		cv.put(TableMain.testnum, oldtestnum + 1);
		cv.put(TableMain.timestart, cartype.start_time);
		cv.put(TableMain.timeend, cartype.end_time);
		cv.put(TableMain.printdata,printdata);
		if(cartype.result == 1)
			cv.put(TableMain.result, "OK");
		else
			cv.put(TableMain.result, "N.OK");
		cv.put(TableMain.logpath,m_com.m_log.getFilePath()); // 将日志记录文件村粗进入数据库中
		cv.put(TableMain.logfileName,m_com.m_log.getFileName());
		cv.put(TableMain.update,Common.updata_isok ? "已上传":"未上传"); // 将数据是否已成功上传到web服务端存入数据库中
		if(Common.Debug) Log.i(TAG,cv.toString());
		db.addmainTable(cv,Common.updata_isok);
		//---------------------第二步，存储详细数据---------------------
		int datanum = db.CreateTableData(new String(cartype.vin));
		db.StartAddMost();
		if(Common.Debug) Log.i(TAG,"查询到的测试次数:" + datanum);
		if(list != null)
		{
			for(int i = 0; i < list.size(); i ++)
			{
				ContentValues cdata = new ContentValues();
				cdata.put(TableData.testnum, oldtestnum + 1);
				cdata.put(TableData.testcode, list.get(i).get("SHOW_ID"));
				cdata.put(TableData.context, list.get(i).get("SHOW_CONTEXT"));
				cdata.put(TableData.testdata, list.get(i).get("SHOW_RESULT"));
				cdata.put(TableData.stand, list.get(i).get("SHOW_CTAND"));
				cdata.put(TableData.result, list.get(i).get("SHOW_TIME"));
				db.addDatatotable(new String(cartype.vin), cdata);
			}
		}

		db.StopAddMost();
		db.close();
		//m_handler.obtainMessage(MSG_Connect_MainSQL, cv).sendToTarget();
	}
	/**
	 * 文件上传线程
	 * @param uploadUrl
	 * @param filePaths
	 * @param id
	 */

	public boolean uploadFiles(String uploadUrl, String filePaths,Long id)
	{
		m_upfile_isok = false;
		MultipartBody.Builder builder = new MultipartBody.Builder().setType(MultipartBody.FORM);
		String fname = filePaths;
		File tempfile = new File(fname);
		//根据文件的后缀名，获得文件类型
		builder.setType(MultipartBody.FORM)
				.addFormDataPart("resultId", String.valueOf(id))// 其他参数信息
				.addFormDataPart( //给Builder添加上传的文件
						"files",  //请求的名字
						tempfile.getName(), //文件的文字，服务器端用来解析的
						RequestBody.create(MediaType.parse("multipart/form-data"), tempfile)//创建RequestBody，把上传的文件放入
				);
		MultipartBody requestBody = builder.build();
		Request request = new Request.Builder()
				.url(uploadUrl)
				.post(requestBody)
				.build();
		OkHttpClient client = new OkHttpClient.Builder()
				.connectTimeout(10000, TimeUnit.SECONDS)
				.readTimeout(10000, TimeUnit.SECONDS)
				.writeTimeout(10000, TimeUnit.SECONDS).build();
		client.newCall(request).enqueue(new Callback() {
			@Override
			public void onFailure(Call call, final IOException e) {
				Log.e("TAG", "返回内容===失败>:" + e.toString());
				m_com.m_log.PrintLog( e.toString());
			}

			@Override
			public void onResponse(Call call, Response response) throws IOException {
				String result = response.body().string();
				Log.e("TAG", "返回内容===成功>:" + result);
				m_com.m_log.PrintLog(result);
				m_upfile_isok = true;
			}
		});
		return m_upfile_isok;
	}
//	//上传日志文件至服务器
//	boolean UploadLogfiletoServer(ServerSocket Psocket)
//	{
//		boolean isok = false;
//		showTip("上传日志...");
//		//t_com.GetLogfileName()
//		//t_com.OpenLogfile("20211113/LUZBGACC3MA000947-111054.txt");
//		String vfilename = bluetooth.GetLogfileName();
//		int upmax = 50000;
//		int uplen = 0;
//		long vlen = bluetooth.GetLogfileSize();
//		char [] v_buf = new char[(int) (vlen + 10)];
//		long v_getlen = bluetooth.readLogfile(v_buf);
//		if(v_getlen <= 0) return false;
//		//分段上传数据
//		//请求上传头部信息
//		byte [] Readbuf = new byte[128];
//		String v_up = "L:" + v_getlen + "," + vfilename;
//		for(int k = 0; k < 3; k ++)
//		{
//			isok = Psocket.sendDataToServer(Commonfunc.getByteLenOfFive(v_up));
//			if(isok) //上传后续数据
//			{
//				int uptime = (int) (v_getlen / upmax);
//				if((v_getlen % upmax) != 0)
//					uptime ++;
//				for(int s = 0; s < uptime; s ++)
//				{
//					if(s == (uptime - 1))
//						uplen = (int) (v_getlen % upmax);
//					else
//						uplen = upmax;
//					char [] upstr = new char[uplen];
//					System.arraycopy(v_buf, upmax * s, upstr, 0, uplen);
//					int readlen = Psocket.sendDataToServer(new String(upstr),Readbuf);
//					if(readlen > 0)
//					{
//						byte [] str = new byte[readlen];
//						System.arraycopy(Readbuf, 0, str, 0, readlen);
//						if(new String(str).equals("retry"))
//						{
//							s --;Sleep(50);
//						}
//					}
//					showTip("上传日志:" + v_getlen + "\\" + (upmax * s + uplen) + " bytes...");
//				}
//				break;
//			}
//		}
//		return isok;
//	}
//	/**
//	 * 保存数据到本地数据库
//	 * @param printData 打印数据
//	 * @param list      详细数据
//	 * @param mesData   上传MES数据,有就传，没有就不传
//	 */
//	private void saveDataToNativeDb(String printData,ArrayList<Map<String, String>> list,String... mesData){
//		DbAdapter db = new DbAdapter();
//		db.open();
//		//---------------------第一步存主数据库---------------------
//		int testnum = db.queryMainTestNum(new String(cartype.vin));
//		ContentValues cv = new ContentValues();
//		cv.put(TableMain.VIN, new String(cartype.vin));
//		cv.put(TableMain.CAR, cartype.car);
//		cv.put(TableMain.STATION, cartype.getStationsList().get(Common.stationPos));
//		cv.put(TableMain.RESULT, "2".equals(cartype.result) ? Common.NG : Common.OK);
//		cv.put(TableMain.PRINT_DATA, printData);
//		cv.put(TableMain.TIME, Commonfunc.getDateTime());
//		cv.put(TableMain.TEST_NUM, testnum + 1);
//		cv.put(TableMain.UPLOAD_PC, uploadPC ? "已上传" : "未上传");
//		if(mesData.length > 0){
//			cv.put(TableMain.MES_DATA, mesData[0]);
//			cv.put(TableMain.UPLOAD_MES, uploadMes ? "已上传" : "未上传");
//		}
//
//		db.updateTable(TableMain.NAME, cv);
//		//---------------------第二步，存储详细数据---------------------
//		db.createDataTable(new String(cartype.vin));
//		db.startTransaction();
//		if(list != null){
//			for(int i = 0; i < list.size(); i ++){
//				ContentValues data = new ContentValues();
//				data.put(TableData.TESTNAME, list.get(i).get(Common.TESTNAME));
//				data.put(TableData.CONTENT, list.get(i).get(Common.CONTENT));
//				data.put(TableData.RESULT, list.get(i).get(Common.RESULT));
//				db.updateTable(new String(cartype.vin), data);
//			}
//		}
//		db.stopTransaction();
//		db.close();
//	}

	private boolean SetCanInitial(String module,int [] Pcanid)
	{
		//获取配置文件路径
		String v_path = cartype.carDirectory + "can.ini";
		Ini inican;
		try {
			bluetooth.mLog.PrintLog("Set Module:" + module);
			inican = new Ini(new File(v_path));
			Profile.Section sec = inican.get(module);
			if(sec == null) return false;
			int mode = 0;
			if(sec.get("CAN").equals("PCAN"))
				mode = 1;	//20150801后重新纠正
			else if(sec.get("CAN").equals("BCAN"))
				mode = 2;
			if(Common.Debug) Log.i(TAG,"CAN_mode = " + mode);
			int baud = Integer.valueOf(sec.get("BAUD"));
			if(Common.Debug) Log.i(TAG,"BAUD = " + baud);
			byte [] can_addr = new byte[4];
			String t1 = sec.get("ID_SEND");
			int v_id = Commonfunc.HexStringtoInt(t1);
			if(Pcanid != null)
				Pcanid[0] = v_id;
			can_addr[0] = (byte) ((v_id / 0x100) & 0xFF);
			can_addr[1] = (byte) (v_id & 0xFF);
			String t2 = sec.get("ID_RECV");
			v_id = Commonfunc.HexStringtoInt(t2);
			if(Pcanid != null)
				Pcanid[1] = v_id;
			can_addr[2] = (byte) ((v_id / 0x100) & 0xFF);
			can_addr[3] = (byte) (v_id & 0xFF);
			if(Common.Debug) Log.i(TAG,"CAN_ID = " + Commonfunc.bytesToHexString(can_addr, 0,can_addr.length));
			boolean init = SetCanInit_new(mode,baud);
			if(!init){//初始化失败
				t_isok=false;
				cartype.result = 2;
			}
			return init;
		} catch (InvalidFileFormatException e1) {
			e1.printStackTrace();
		} catch (IOException e1) {
			e1.printStackTrace();
		}
		return true;
	}

	/**
	 * 模块初始化信息
	 * @param module 模块
	 * @isFlash 刷写模式的话就随意传个值，否则不传
	 * @return 是否初始化成功
	 */
	private boolean SetCanInitial_Flash(String module,int [] Pcanid)
	{
		//获取配置文件路径
		String v_path = cartype.carDirectory + "/" + "can.ini";
		Ini inican;
		try {
			inican = new Ini(new File(v_path));
			Profile.Section sec = inican.get(module);
			int mode = 0;
			if(sec.get("CAN").equals("PCAN"))
				mode = 1;
			else
				mode = 2;
			if(Common.Debug) Log.i(TAG,"CAN_mode = " + mode);
			int baud = Integer.valueOf(sec.get("BAUD"));
			if(Common.Debug) Log.i(TAG,"BAUD = " + baud);
			byte [] can_addr = new byte[4];
			String t1 = sec.get("ID_SEND");
			int v_id = Commonfunc.HexStringtoInt(t1);
			can_addr[0] = (byte) ((v_id / 0x100) & 0xFF);
			can_addr[1] = (byte) (v_id & 0xFF);
			if(Pcanid != null)
				Pcanid[0] = v_id;
			String t2 = sec.get("ID_RECV");
			v_id = Commonfunc.HexStringtoInt(t2);
			can_addr[2] = (byte) ((v_id / 0x100) & 0xFF);
			can_addr[3] = (byte) (v_id & 0xFF);
			if(Pcanid != null)
				Pcanid[1] = v_id;
			if(Common.Debug) Log.i(TAG,"CAN_ID = " + Commonfunc.bytesToHexString(can_addr, 0,can_addr.length));
			return SetCanInit_Flash(mode,baud,can_addr,2);
		} catch (InvalidFileFormatException e1) {
			e1.printStackTrace();
		} catch (IOException e1) {
			e1.printStackTrace();
		}
		return true;
	}

	//设置can初始化
	private boolean SetCanInit_Flash(int mode,long baud,byte [] Pbuf,int num)
	{
		int i = 0;
		for(i = 0; i < Common.cmd_freq; i ++)
		{
			if(m_com.SetCanBaud(baud)) break;
			Sleep(50);
		}
		if(i >= Common.cmd_freq){
			return false;
		}

		if(Common.Debug) Log.i(TAG,"设置波特率成功： " + baud);
		Sleep(50);
		for(i = 0; i < Common.cmd_freq; i ++)
		{
			if(m_com.SetCanFilter(Pbuf,num)) break;
			Sleep(50);
		}
		if(i >= Common.cmd_freq) return false;
		if(Common.Debug) Log.i(TAG,"设置CAN id成功： " + Commonfunc.bytesToHexString(Pbuf,0, Pbuf.length));
		Sleep(50);
		for(i = 0; i < Common.cmd_freq; i ++)
		{
			if(m_com.SetCanMode(mode)) break;
			Sleep(50);
		}
		if(i >= Common.cmd_freq) return false;
		if(Common.Debug) Log.i(TAG,"设置CanMode成功：" + mode);
		Sleep(50);
		for(i = 0; i < Common.cmd_freq; i ++)
		{
			if(m_com.SetCommunTimer(2,2000,3000,0)) break;
			Sleep(50);
		}
		if(i >= Common.cmd_freq) return false;
		byte [] canbuf={0x30,0x00,0x0A,0x00,0x00,0x00,0x00,0x00};
		for(i = 0; i < Common.cmd_freq; i ++)
		{
			if(m_com.SetCanAutoFrame(canbuf, 8)) break;
			Sleep(50);
		}
		if(i >= Common.cmd_freq) return false;
		if(Common.Debug) Log.i(TAG,"设置CAN 过滤成功!");
		Sleep(50);
		return true;
	}

	private boolean SetCanInit_new(int mode,long baud)
	{
		if(Common.CanMode == mode) return true; //诊断新指令，设置过一次就不用再设置20200906
		int i = 0;
		for(i = 0; i < Common.cmd_freq; i ++)
		{
			if(m_com.SetCanBaud(baud)) break;
			Sleep(50);
		}
		if(i >= Common.cmd_freq) return false;
		if(Common.Debug) Log.i(TAG,"设置波特率成功： " + baud);
		Sleep(20);
		for(i = 0; i < Common.cmd_freq; i ++)
		{
			if(m_com.SetCanMode(mode)) break;
			Sleep(50);
		}
		if(i >= Common.cmd_freq) return false;
		Common.CanMode = mode;
		if(Common.Debug) Log.i(TAG,"设置CanMode成功：" + mode);
		Sleep(20);
		for(i = 0; i < Common.cmd_freq; i ++)
		{
			if(m_com.SetCommunTimer(10,2000,5000,20)) break;
			Sleep(50);
		}
		if(i >= Common.cmd_freq) return false;
		if(Common.Debug) Log.i(TAG,"设置CAN 时序成功!");
		Sleep(50);
		byte [] canbuf={0x30,0x00,0x0A,0x00,0x00,0x00,0x00,0x00};
		for(i = 0; i < Common.cmd_freq; i ++)
		{
			if(m_com.SetCanAutoFrame(canbuf, 8)) break;
			Sleep(50);
		}
		if(i >= Common.cmd_freq) return false;
		if(Common.Debug) Log.i(TAG,"设置CAN 过滤成功!");
		Sleep(50);
		return true;
	}


	//设置can初始化
	private boolean SetCanInit(int mode,long baud,byte [] Pbuf,int num)
	{
		int i = 0;
		for(i = 0; i < Common.cmd_freq; i ++)
		{
			if(m_com.SetCanBaud(baud)) break;
			Sleep(50);
		}
		if(i >= Common.cmd_freq) return false;
		if(Common.Debug) Log.i(TAG,"设置波特率成功： " + baud);
		Sleep(50);
		for(i = 0; i < Common.cmd_freq; i ++)
		{
			if(m_com.SetCanFilter(Pbuf,num)) break;
			Sleep(50);
		}
		if(i >= Common.cmd_freq) return false;
		if(Common.Debug) Log.i(TAG,"设置CAN id成功： " + Commonfunc.bytesToHexString(Pbuf,0, Pbuf.length));
		Sleep(50);
		for(i = 0; i < Common.cmd_freq; i ++)
		{
			if(m_com.SetCanMode(mode)) break;
			Sleep(50);
		}
		if(i >= Common.cmd_freq) return false;
		if(Common.Debug) Log.i(TAG,"设置CanMode成功：" + mode);
		Sleep(50);
		for(i = 0; i < Common.cmd_freq; i ++)
		{
			if(m_com.SetCommunTimer(10,2000,5000,20)) break;
			Sleep(50);
		}
		if(i >= Common.cmd_freq) return false;
		if(Common.Debug) Log.i(TAG,"设置CAN 时序成功!");
		Sleep(50);
		//设置CAN自动回复帧
		byte [] autocmd = {0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
		for(i = 0; i < Common.cmd_freq; i ++)
		{
			if(m_com.SetCanAutoFrame(autocmd, 8)) break;
			Sleep(50);
		}
		if(i >= Common.cmd_freq) return false;
		if(Common.Debug) Log.i(TAG,"设置CAN 时序成功!");
		Sleep(50);
		return true;
	}

	private boolean setCanInit(String module, String... isFlash){
		boolean result;
		if(isFlash.length > 0){
			result = bluetooth.setCanInit(module, isFlash[0]);
		}else{
			result = bluetooth.setCanInit(module);
		}
		if(!result){//初始化失败
			showProcessList("CAN初始化失败",Common.NULL, Common.NG);
		}
		return result;
	}
	private boolean SetCanMode(int Pmode,long Pbaud)
	{
		int i;
		for(i = 0; i < Common.CMD_REQUEST; i ++)
		{
			if(bluetooth.setCanBaud(Pbaud)) break;
			Commonfunc.sleep(50);
		}
		if(i >= Common.CMD_REQUEST) return false;
		for(i = 0; i < Common.CMD_REQUEST; i ++)
		{
			if(bluetooth.setCanMode(Pmode)) break;
			Commonfunc.sleep(50);
		}
		if(i >= Common.CMD_REQUEST) return false;

		return true;
	}
	private boolean SetCanInitTimer(int P4)
	{
		int i;
		for(i = 0; i < Common.CMD_REQUEST; i ++)
		{
			if(bluetooth.setCommunTimer(10,2000,3000,P4)) break;
			Commonfunc.sleep(50);
		}
		if(i >= Common.CMD_REQUEST) return false;
		//if(Common.DEBUG) Log.i(TAG,"设置CAN 时序成功!");
		return true;
	}
	private boolean SetStandCanAutoFrame(int Pid,byte [] Pdata)
	{
		int i;
		for(i = 0; i < Common.CMD_REQUEST; i ++)
		{
			if(bluetooth.SetStandCanAutoFrame(Pid, Pdata, Pdata.length)) break;
			Commonfunc.sleep(50);
		}
		if(i >= Common.CMD_REQUEST) return false;
		//if(Common.Debug) Log.i(TAG,"设置CAN 时序成功!");
		return true;
	}
	/**
	 * 执行对应模块
	 */
	public void exeFunctionModule(String modeName,Section sec)
	{
		if(Common.stationPos == 3 && (cartype.car.indexOf("62") > 0 || cartype.car.indexOf("63") > 0 || cartype.car.indexOf("FL") > 0)) //公共刷写
		{
			if(modeName.equals("EMS刷写1")){
				fun_JX65_Ems1781(sec, "EMS1");
			}
			else if(modeName.equals("EMS刷写2")){
				fun_JX65_Ems1788(sec, "EMS1");
			}
			else if(modeName.equals("EMS刷写3")){
				fun_JX65_EmsUP8(sec,"EMS1");
			}
			else if(modeName.equals("EMS刷写4")){
				fun_JX65_EmsUD8(sec, "EMS1");
			}
			else if(modeName.equals("TCU刷写1")){
				fun_JX65_TcuFlash1(sec, "TCU1");
			}
			else if(modeName.equals("TCU刷写2")){
				fun_JX65_TcuFlash2(sec, "TCU2");
			}
			else if(modeName.equals("TCU刷写3")){
				fun_Stand_CX62C_TCUFlash1(sec, "TCU3");
			}
			else if (modeName.equals("FCM刷写1")) {
				fun_PHEV_Fcmflash(sec,"FCM1");
			}
			else if (modeName.equals("FRM刷写1")) {
				fun_PHEV_FrmFlash(sec,"FRM1");
			}
		}
		else if(cartype.car.equals("Q22_2020") || cartype.car.equals("Q22_IRAQ")){
			if(modeName.equals("EMS1")){
				fun_Q2020_EMS1(sec);
			}else if(modeName.equals("EPS1"))
			{
				fun_KM23_EPS1(sec);
			}
			else if(modeName.equals("OBD检查")){
				fun_new_Stand_OBD(sec);
			}else {
				fun_new_Stand_ReadInfo(sec);
			}
		}else if(cartype.car.equals("Q22LEV") || cartype.car.equals("Q22国六")){
			if(modeName.equals("BCM1")){
				fun_Q22LEV_BCM1(sec);
			}else if(modeName.equals("VCU1")){
				fun_Q22LEV_VCU1(sec);
			}else if(modeName.equals("TBOX1")){
				fun_Q22LEV_TBOX1(sec);
			}else if(modeName.equals("EPS1")){
				fun_KM23_EPS1(sec);
			}else if(modeName.equals("EMS1")){
				fun_Q22LEV_EMS1(sec);
			}
			else if(modeName.equals("OBD检查")){
				fun_new_Stand_OBD(sec);
			}else {
				fun_new_Stand_ReadInfo(sec);
			}
		}else if(cartype.car.equals("KQ92") || cartype.car.equals("KQ93")){
			if(modeName.equals("BCM1")){
				fun_KQ92_BCM1(sec);
			}else if(modeName.equals("ABS1") || modeName.equals("EPS1")){
				fun_KQ92_ABS1(sec);
			}else if(modeName.equals("EMS1")){
				fun_KQ92_EMS1(sec);
			}
			else if(modeName.equals("OBD检查")){
				fun_new_Stand_OBD(sec);
			}else {
				fun_new_Stand_ReadInfo(sec);
			}
		}else if(cartype.car.equals("KM23")){
			if(modeName.equals("PEPS1")){
				fun_KM23_PEPS1(sec);
			}else if(modeName.equals("BCM1") || modeName.equals("ICM1")){
				fun_KM23_BCM1(sec);
			}else if(modeName.equals("EMS1")){
				fun_KM23_EMS1(sec);
			}else if(modeName.equals("ABS1")){
				fun_KM23_ABS1(sec);
			}else if(modeName.equals("EPS1")){
				fun_KM23_EPS1(sec);
			}else if(modeName.equals("ESP1")){
				fun_KM23_ESP1(sec);
			}else if(modeName.equals("APM1")){
				fun_CX62_APM1(sec);
			}
			else if(modeName.equals("OBD检查")){
				fun_new_Stand_OBD(sec);
			}else {
				fun_new_Stand_ReadInfo(sec);
			}
		}else if(cartype.car.equals("K50EV")){
			if(modeName.equals("BCM1")){
				fun_KM23_BCM1(sec);
			}else if(modeName.equals("ABS1")){
				fun_KM23_ABS1(sec);
			}else if(modeName.equals("EPS1")){
				fun_KM23_EPS1(sec);
			}else if(modeName.equals("VCU1")){
				fun_K50EV_VCU1(sec);
			}else if(modeName.equals("TBOX1")){
				fun_K50EV_TBOX1(sec);
			}
			else if(modeName.equals("OBD检查")){
				fun_new_Stand_OBD(sec);
			}else {
				fun_new_Stand_ReadInfo(sec);
			}
		}else if(cartype.car.equals("KL33EV")){
			if(modeName.equals("BCM1")){
				fun_KL33EV_BCM1(sec);
			}else if(modeName.equals("VCU1")){
				fun_KL33EV_VCU1(sec);
			}else if(modeName.equals("MCU1") || modeName.equals("BMS1")){
				fun_KL33EV_MCU1(sec);
			}else if(modeName.equals("TBOX1")){
				fun_KL33EV_TBOX1(sec);
			}else if(modeName.equals("ACM1") || modeName.equals("DCDC1")
					|| modeName.equals("PDU1") || modeName.equals("EPS1")){
				fun_KL33EV_ACM1(sec);
			}
			else if(modeName.equals("OBD检查")){
				fun_new_Stand_OBD(sec);
			}else {
				fun_new_Stand_ReadInfo(sec);
			}
		}else if(cartype.car.equals("CX62") || cartype.car.equals("T1NFL1")){
			if(modeName.equals("PEPS1")){
				fun_CX62_PEPS1(sec);
			}else if(modeName.equals("BCM1")){
				fun_CX62_BCM1(sec);
			}else if(modeName.equals("BCM2")){
				fun_CX62_BCM2(sec);
			}else if(modeName.equals("ICM1") || modeName.equals("RADAR1") ||
					modeName.equals("FCW1")){
				fun_CX62_ICM1(sec);
			}else if(modeName.equals("RRM1") || modeName.equals("TBOX1")){
				fun_CX62_TBOX1(sec);
			}else if(modeName.equals("ABS1") || modeName.equals("ESP1")){
				fun_CX62_ABS1(sec);
			}else if(modeName.equals("EPB1")){
				fun_CX62_EPB1(sec);
			}else if(modeName.equals("EMS1")){
				fun_CX62_EMS1(sec);
			}else if(modeName.equals("APM1") || modeName.equals("APM2")){
				fun_CX62_APM1(sec);
			}else if(modeName.equals("BM1")){
				fun_CX62_BM1(sec);
			}else if(modeName.equals("TPMS1")){
				//if (Common.stationPos==2)
				//{fun_CX62_TPMS1(sec);}
				//else fun_T1P_TPMS1(sec);
				fun_T1N_TPMS1(sec);
			} else if (modeName.equals("GBC1")) {
				fun_CX62B_GBC1(sec);
			}else if(modeName.equals("OBD检查")){
				fun_new_Stand_OBD(sec);
			}else if (modeName.equals("ReadInfo")|| modeName.equals("ClearAllDTC") || modeName.equals("ReadAllDTC") || modeName.equals("ClearAllDtc") || modeName.equals("ReadAllDtc") || modeName.equals("ReadConfig")){
				fun_new_Stand_ReadInfo(sec);
			}
			else {
				fun_T1N_stand_module(sec);
			}
		}else if(cartype.car.equals("CX62B")){//TODO
			if(modeName.equals("PEPS1") || modeName.equals("IMMO1")){
				fun_CX62B_PEPS1(sec);
			} else if (modeName.equals("IHU1") ||modeName.equals("EGSM1")
					||modeName.equals("ABS1") ||modeName.equals("WCM(50W)1")
					||modeName.equals("ERM1")) {
				fun_NEW_Stand_module(sec);
			} else if (modeName.equals("EPB1")) {
				fun_CX62_EPB1(sec);
			} else if(modeName.equals("ICM1") || modeName.equals("EPS1") ||
					modeName.equals("FIPM1") || modeName.equals("PLG1") ||
					modeName.equals("CGW1") || modeName.equals("CEM1") ||
					modeName.equals("RADAR1")){
				fun_CX62_ICM1(sec);
			}else if(modeName.equals("BDM1")){
				fun_CX62_BCM2(sec);
			}else if(modeName.equals("TBOX1") || modeName.equals("RRM1")){
				fun_CX62_TBOX1(sec);
			}else if(modeName.equals("FCM1")){
				fun_CX62B_FCM1(sec);
			}else if(modeName.equals("FRM1")){
				fun_CX62B_FRM1(sec);
			}else if(modeName.equals("ABM1") || modeName.equals("FWS1") ){
				fun_CX62B_ABM1(sec);
			}else if(modeName.equals("DVR1") || modeName.equals("GSM1") ||
					modeName.equals("DMS1") ){
				fun_CX62B_DVR1(sec);
			}else if(modeName.equals("TCM1") || modeName.equals("TCU1")  || modeName.equals("TCU2")){
				fun_CX62B_TCM1(sec);
			}else if(modeName.equals("GBC1")){
				fun_CX62B_GBC1(sec);
			}else if(modeName.equals("ESP1")){
				fun_CX62_ABS1(sec);
			}else if(modeName.equals("EMS1")){
				fun_CX62_EMS1(sec);
			}else if(modeName.equals("APM1") || modeName.equals("APM2")){
				fun_CX62B_APM1(sec);
			}else if(modeName.equals("TPMS1")){
				fun_T1N_TPMS1(sec);
			}else if(modeName.equals("SMM_READ1")){
				fun_CX62B_SMM_READ1(sec);
			}else if(modeName.equals("SMM_WRITE1")){
				fun_CX62B_SMM_WRITE1(sec);
			}
			else if(modeName.equals("EMS刷写1")){
				fun_JX65_Ems1781(sec, "EMS1");
			}
			else if(modeName.equals("EMS刷写3")){
				fun_JX65_EmsUP8(sec,"EMS1");
			}
			else if(modeName.equals("EMS刷写4")){
				fun_JX65_EmsUD8(sec, "EMS1");
			}
			else if(modeName.equals("TCU刷写1")){
				fun_JX65_TcuFlash1(sec, "TCU1");
			}
			else if(modeName.equals("TCU刷写2")){
				fun_JX65_TcuFlash2(sec, "TCU2");
			}
			else if(modeName.equals("TCU刷写3")){
				fun_Stand_CX62C_TCUFlash1(sec, "TCU3");
			}
			else if(modeName.equals("OBD检查")){
				fun_new_Stand_OBD(sec);
			}else if (modeName.equals("ReadInfo")|| modeName.equals("ClearAllDTC") || modeName.equals("ReadAllDTC") || modeName.equals("ClearAllDtc") || modeName.equals("ReadAllDtc") || modeName.equals("ReadConfig")){
				fun_new_Stand_ReadInfo(sec);
			}
			else {
				fun_T1N_stand_module(sec);
			}
		} else if (cartype.car.equals("T1NPHEV")) {
			if (modeName.equals("ReadInfo")|| modeName.equals("ClearAllDtc") || modeName.equals("ReadAllDtc") || modeName.equals("ReadConfig")){
				fun_T1N_Stand_ReadInfo(sec);
			}
			else if (modeName.equals("PEPS1")) { //完成  钥匙匹配
				fun_T1N_PEPS1(sec);
			}
			else if (modeName.equals("ESP2")) {
				fun_T1N_ESP2(sec);
			}
			else if(modeName.equals("APM1") && Common.stationPos==1){
				fun_CX62_APM1(sec);
			}
			else if(modeName.equals("TPMS1")){
				fun_T1N_TPMS1(sec);
			}
			else if(modeName.equals("OBD检查")){
				fun_T1N_Stand_OBD(sec);
			}
			else if (modeName.equals("DHM1")) {
				fun_T1N_DHM(sec);
			}
			else if (modeName.equals("SEAT1")){
				if (Common.stationPos==0){
					fun_T1N_new_module(sec);
				} else if (Common.stationPos==2) {
					fun_T1N_SEAT(sec);
				}
			}
			else if (modeName.equals("TCU刷写1")) {
				fun_T1NPHEV_TcuFlash(sec,"TCU1");
			}
			else if (modeName.equals("EMS刷写1")) {
				fun_PHEV_Ecuflash(sec,"ECU1");
			}
			else if(modeName.equals("EMS刷写3")){
				fun_JX65_EmsUP8(sec,"EMS1");
			}
			else if(modeName.equals("EMS刷写4")){
				fun_JX65_EmsUD8(sec, "EMS1");
			}
			else if (modeName.equals("FCM刷写1")) {
				fun_PHEV_Fcmflash(sec,"FCM1");
			}
			else if (modeName.equals("FRM刷写1")) {
				fun_PHEV_FrmFlash(sec,"FRM1");
			}
			else {
				fun_T1N_stand_module(sec);
			}
		}
		else if (cartype.car.equals("T1PFL3")) {
			if  (modeName.equals("ReadInfo")|| modeName.equals("ClearAllDtc") || modeName.equals("ReadAllDtc") || modeName.equals("ReadConfig")){
				fun_T1P_Stand_ReadInfo(sec);
			}else if(modeName.equals("PEPS1")){//TODO
				fun_T1P_PEPS1(sec);
			}else if(modeName.equals("BDM1")){
				if (Common.stationPos==0){
					fun_T1P_BDM1(sec);
				} else if (Common.stationPos==1) {
					fun_T1P_APM1(sec);
				}
			}else if (modeName.equals("TCU1")){
				fun_T1P_TCU_module(sec);
			}else if (modeName.equals("OBD检查")) {
				fun_T1N_Stand_OBD(sec);
			}else if(modeName.equals("EMS刷写1")){
				fun_JX65_Ems1781(sec, "EMS1");
			}
			else if(modeName.equals("TCU刷写1")){
				fun_JX65_TcuFlash1(sec, "TCU1");
			}
			else if(modeName.equals("TCU刷写2")){
				fun_JX65_TcuFlash2(sec, "TCU2");
			}
			else if(modeName.equals("TCU刷写3")){
				fun_Stand_CX62C_TCUFlash1(sec, "TCU3");
			} else if (modeName.equals("EMS刷写2")) {
				fun_JX65_Ems1788(sec,"EMS2");
			}
			else if(modeName.equals("TPMS1")){
				fun_T1N_TPMS1(sec);
			}
			else
				fun_T1P_Stand_module(sec);
		} else if (cartype.car.equals("T1PPHEV")) {
			if  (modeName.equals("ReadInfo")|| modeName.equals("ClearAllDtc") || modeName.equals("ReadAllDtc") || modeName.equals("ReadConfig")){
				fun_T1P_Stand_ReadInfo(sec);
			}
			else if(modeName.equals("PEPS1")) {//TODO
				fun_T1P_PEPS2(sec);
			}
			else if (modeName.equals("BDM1")) {
				if (Common.stationPos == 0) {
					fun_T1P_ICM1(sec);
				} else if (Common.stationPos == 1) {
					fun_T1P_APM1(sec);
				}
			}
			else if (modeName.equals("AMP1")) {
				fun_T1P_TCU_module(sec);
			}
			else if(modeName.equals("TPMS1")){
				fun_T1N_TPMS1(sec);
			}
			else if (modeName.equals("OBD检查")) {
				fun_T1N_Stand_OBD(sec);
			}
			else if (modeName.equals("TCU刷写2")) {
				fun_PHEV_TcuFlash(sec,"TCU2");
			}
			else if (modeName.equals("EMS刷写1")) {
				fun_PHEV_Ecuflash(sec,"EMS1");
			}
			else if (modeName.equals("FCM刷写1")) {
				fun_PHEV_Fcmflash(sec,"FCM1");
			}
			else if (modeName.equals("FRM刷写1")) {
				fun_PHEV_FrmFlash(sec,"FRM1");
			}
			else {
				fun_T1P_Stand_module(sec);
			}
		} else if(cartype.car.equals("KX63FL")){
			if(modeName.equals("PEPS1")){
				fun_CX62_PEPS1(sec);
			}else if(modeName.equals("BCM1")){
				fun_CX62_BCM1(sec);
			}else if(modeName.equals("BCM2")){
				fun_CX62_BCM2(sec);
			}else if(modeName.equals("ICM1") || modeName.equals("RADAR1") ||
					modeName.equals("IPM1") || modeName.equals("FCW1")){
				fun_CX62_ICM1(sec);
			}else if(modeName.equals("TBOX1") || modeName.equals("RRM1") ){
				fun_KX63_TBOX1(sec);
			}else if(modeName.equals("ABS1") || modeName.equals("ESP1")){
				fun_CX62_ABS1(sec);
			}else if(modeName.equals("EPB1")){
				fun_CX62_EPB1(sec);
			}else if(modeName.equals("EMS1")){
				fun_CX62_EMS1(sec);
			}else if(modeName.equals("APM1") || modeName.equals("APM2")){
				fun_CX62_APM1(sec);
			}else if(modeName.equals("GBC1")){
				fun_CX62B_GBC1(sec);
			}else if(modeName.equals("BM1")){
				fun_CX62_BM1(sec);
			}else if(modeName.equals("ABM1")){
				fun_CX62B_ABM1(sec);
			}else if(modeName.equals("TPMS1")){
				fun_T1N_TPMS1(sec);
			}
			else if(modeName.equals("TCU刷写1")){
				fun_JX65_TcuFlash1(sec, "TCU1");
			}
			else if(modeName.equals("TCU刷写2")){
				fun_JX65_TcuFlash2(sec, "TCU2");
			}
			else if(modeName.equals("TCU刷写3")){
				fun_Stand_CX62C_TCUFlash1(sec, "TCU2");
			}
			else if(modeName.equals("OBD检查")){
				fun_new_Stand_OBD(sec);
			}else {
				fun_new_Stand_ReadInfo(sec);
			}
		} else if (cartype.car.equals("KX63A")) {
			if(modeName.equals("PEPS1")){
				fun_KX63A_PEPS1(sec);
			}else if(modeName.equals("ICM1") || modeName.equals("EPS1") ||
					modeName.equals("FIPM1") || modeName.equals("PLG1") ||
					modeName.equals("CGW1") || modeName.equals("CEM1")){
				fun_CX62_ICM1(sec);
			} else if (modeName.equals("IPM1")||modeName.equals("ABS1")
					||modeName.equals("TCU1")) {
				fun_NEW_Stand_module(sec);
			} else if(modeName.equals("BDM1")){
				fun_CX62_BCM2(sec);
			}else if(modeName.equals("TBOX1") || modeName.equals("RRM1")){
				fun_CX62_TBOX1(sec);
			}else if(modeName.equals("FCM1")){
				fun_CX62B_FCM1(sec);
			}else if(modeName.equals("FRM1")){
				fun_CX62B_FRM1(sec);
			}else if(modeName.equals("ABM1") || modeName.equals("FWS1")){
				fun_CX62B_ABM1(sec);
			}else if(modeName.equals("DVR1") || modeName.equals("DMS1")|| modeName.equals("GSM1")){
				fun_CX62B_DVR1(sec);
			}else if(modeName.equals("TCM1")){
				fun_CX62B_TCM1(sec);
			}else if(modeName.equals("GBC1")){
				fun_CX62B_GBC1(sec);
			}else if(modeName.equals("ESP1")){
				fun_CX62_ABS1(sec);
			}else if(modeName.equals("EMS1")){
				fun_CX62_EMS1(sec);
			}else if(modeName.equals("APM1")){
				fun_CX62_APM1(sec);
			}else if(modeName.equals("APM2")){
				fun_KX63A_APM1(sec);
			}else if(modeName.equals("BM1")){
				fun_CX62_BM1(sec);
			}else if(modeName.equals("TPMS1")){
				fun_T1N_TPMS1(sec);
			}
			else if(modeName.equals("OBD检查")){
				fun_new_Stand_OBD(sec);
			}
			else if(modeName.equals("TCU刷写1")){
				fun_JX65_TcuFlash1(sec, "TCU1");
			}
			else if(modeName.equals("TCU刷写2")){
				fun_JX65_TcuFlash2(sec, "TCU2");
			}
			else if(modeName.equals("TCU刷写3")){
				fun_Stand_CX62C_TCUFlash1(sec, "TCU3");
			}
			else {
				fun_new_Stand_ReadInfo(sec);
			}
		} else if(cartype.car.equals("KX63FLB"))
		{
			if(modeName.equals("PEPS1")){//TODO
				fun_KX63A_PEPS1(sec);
			}else if(modeName.equals("ICM1") || modeName.equals("EPS1") ||
					modeName.equals("FIPM1") || modeName.equals("PLG1") ||
					modeName.equals("CGW1") || modeName.equals("CEM1")){
				fun_CX62_ICM1(sec);
			} else if (modeName.equals("TCU1")) {
				fun_NEW_Stand_module(sec);
			} else if(modeName.equals("BDM1")){
				fun_CX62_BCM2(sec);
			}else if(modeName.equals("TBOX1") || modeName.equals("RRM1")){
				fun_CX62_TBOX1(sec);
			}else if(modeName.equals("FCM1")){
				fun_CX62B_FCM1(sec);
			}else if(modeName.equals("FRM1")){
				fun_CX62B_FRM1(sec);
			}else if(modeName.equals("ABM1") || modeName.equals("FWS1")){
				fun_CX62B_ABM1(sec);
			}else if(modeName.equals("DVR1") || modeName.equals("DMS1")
					|| modeName.equals("GSM1")){
				fun_CX62B_DVR1(sec);
			}else if(modeName.equals("TCM1")){
				fun_CX62B_TCM1(sec);
			}else if(modeName.equals("GBC1")){
				fun_CX62B_GBC1(sec);
			}else if(modeName.equals("ESP1")){
				fun_CX62_ABS1(sec);
			}else if(modeName.equals("EMS1")){
				fun_CX62_EMS1(sec);
			}else if(modeName.equals("APM1")){
				fun_CX62_APM1(sec);
			}else if(modeName.equals("APM2")){
				fun_KX63A_APM1(sec);
			}else if(modeName.equals("BM1")){
				fun_CX62_BM1(sec);
			}else if(modeName.equals("TPMS1")){
				fun_T1N_TPMS1(sec);
			}
			else if(modeName.equals("OBD检查")){
				fun_new_Stand_OBD(sec);
			}
			else if(modeName.equals("TCU刷写1")){
				fun_JX65_TcuFlash1(sec, "TCU1");
			}
			else if(modeName.equals("TCU刷写2")){
				fun_JX65_TcuFlash2(sec, "TCU2");
			}
			else if(modeName.equals("TCU刷写3")){
				fun_Stand_CX62C_TCUFlash1(sec, "TCU3");
			}
			else {
				fun_new_Stand_ReadInfo(sec);
			}
		}
		else if(cartype.car.equals("KX63FLB(2.0T)"))
		{
			if(modeName.equals("PEPS1")){//TODO
				fun_KX63A_PEPS1(sec);
			}else if(modeName.equals("ICM1") || modeName.equals("EPS1") ||
					modeName.equals("FIPM1") || modeName.equals("PLG1") ||
					modeName.equals("CGW1") || modeName.equals("CEM1")){
				fun_CX62_ICM1(sec);
			} else if (modeName.equals("EBS1")) { //todo EBS读取
				fun_NEW_Stand_module(sec);
			} else if(modeName.equals("EPB1")){
			fun_CX62_EPB1(sec);
			}else if(modeName.equals("BDM1")){
				fun_CX62_BCM2(sec);
			}else if(modeName.equals("TBOX1") || modeName.equals("RRM1")){
				fun_CX62_TBOX1(sec);
			}else if(modeName.equals("FCM1")){
				fun_CX62B_FCM1(sec);
			}else if(modeName.equals("FRM1")){
				fun_CX62B_FRM1(sec);
			}else if(modeName.equals("ABM1") || modeName.equals("FWS1")){
				fun_CX62B_ABM1(sec);
			}else if(modeName.equals("DVR1") || modeName.equals("DMS1")|| modeName.equals("GSM1")){
				fun_CX62B_DVR1(sec);
			}else if(modeName.equals("TCM1")){
				fun_CX62B_TCM1(sec);
			}else if(modeName.equals("GBC1")){
				fun_CX62B_GBC1(sec);
			}else if(modeName.equals("ESP1")){
				fun_CX62_ABS1(sec);
			}else if(modeName.equals("EMS1")){
				fun_CX62_EMS1(sec);
			}else if(modeName.equals("APM1")){
				fun_CX62_APM1(sec);
			}else if(modeName.equals("APM2")){
				fun_KX63A_APM1(sec);
			}else if(modeName.equals("BM1")){
				fun_CX62_BM1(sec);
			} else if(modeName.equals("TPMS1")){
				fun_T1N_TPMS1(sec);
			}
			else if(modeName.equals("OBD检查")){
				fun_new_Stand_OBD(sec);
			}
			else if(modeName.equals("TCU刷写1")){
				fun_JX65_TcuFlash1(sec, "TCU1");
			}
			else if(modeName.equals("TCU刷写2")){
				fun_JX65_TcuFlash2(sec, "TCU2");
			}
			else if(modeName.equals("TCU刷写3")){
				fun_Stand_CX62C_TCUFlash1(sec, "TCU3");
			}
			else {
				fun_new_Stand_ReadInfo(sec);
			}
		}
		else if(cartype.car.equals("KQ5") || cartype.car.equals("KQ5A"))
		{
			if(modeName.equals("IMMO1"))
			{
				fun_kQ5_IMMO(sec);
			}else if(modeName.equals("ReadConfig") || modeName.equals("ReadInfo") || modeName.equals("ClearAllDtc") || modeName.equals("ReadAllDtc")){
				fun_new_Stand_ReadInfo(sec);
			}else if(modeName.equals("EMS1")){
				fun_KQ92_EMS1(sec);
			}else if(modeName.equals("OBD检查")){
				fun_new_Stand_OBD(sec);
			}else if(modeName.equals("ABS加注")){
				fun_kQ5_ABS(sec);
			}else {
				fun_kQ5_Stand_module(sec);
			}
		}
		else if(cartype.car.equals("KQ71EV") || cartype.car.equals("GK5030XXYBEV03") || cartype.car.equals("KQ51EV") || cartype.car.equals("KQ53EV") || cartype.car.equals("KT51EV"))
		{
			if(modeName.equals("Version") || modeName.equals("ClearDTC") || modeName.equals("ReadDTC") || modeName.equals("Config"))
			{
				fun_new_Stand_ReadInfo(sec);
			}else if(modeName.equals("EMS1")){
				fun_KQ92_EMS1(sec);
			}
			else if(modeName.equals("OBD检查")){
				fun_new_Stand_OBD(sec);
			}else if(modeName.equals("ABS加注")){
				fun_kQ5_ABS(sec);
			}else
			{
				if(cartype.car.equals("KQ53EV"))
				{
					if((cartype.name.indexOf("KQ55") >= 0 || cartype.name.indexOf("KQ53A") >= 0 || cartype.name.indexOf("KQ53B") >= 0) && modeName.equals("EPS1") && Common.stationPos < 1)
						return;
				}
				fun_kQ5_Stand_module(sec);
			}
		}
		else if(cartype.car.equals("KX65EV"))
		{
			if(modeName.equals("Version") || modeName.equals("ClearDTC") || modeName.equals("ReadDTC") || modeName.equals("Config"))
			{
				fun_new_Stand_ReadInfo(sec);
			}else if(modeName.equals("PEPS1")){
				fun_KX65EV_PEPS1(sec);
			}
			else if(modeName.equals("OBD检查")){
				fun_new_Stand_OBD(sec);
			}else if(modeName.equals("ABS加注")){
				fun_kQ5_ABS(sec);
			}else {
				fun_NEW_Stand_module(sec);
			}
		}
	}

	/*******************************************功能函数*******************************************************************/
	private void fun_CX62_PEPS1(Section section){
		if(!getpin()){
			showProcessList("未获取到PIN或配置码",Common.NULL,Common.NG);
			return;
		}
		byte [] v_escl_status =new byte[10];	//ESCL状态
		byte [] v_tcu_status = new byte[10];	//TCU状态
		byte [] v_immo_status =new byte[10];	//IMMO状态
		byte [] v_ems_status = new byte[10];	//EMS状态
		byte [] v_trans_status = new byte[10];	//转发器状态
		int bcm_time = 6;
		boolean veleo = false;
		int Pid = Integer.valueOf(section.get("MODULE_ID"));
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepId = Pid + i;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				//---------------------发送前处理---------------------
				if(i == 1){
					if(cartype.getMap("BM")>0 || veleo){
						if(!SetCanInitial("PEPS1",canid)) return;
					}else{
						if(!SetCanInitial("BCM1",canid)) return;
					}
				}else if(i == 9 || i == 36 || i == 44 || i == 71 || i == 81|| i == 89){		//切换至IMMO
					if(!SetCanInitial("IMMO1",canid)) return;
				}else if(i == 25 || i == 42){	//切换至EMS
					if(!SetCanInitial("EMS1",canid)) return;
				}else if(i == 68 || i == 77){ //切换至TCU
					if(!SetCanInitial("TCU1",canid))return;
				}else if(i == 2 || i == 88 || i == 91){ //切换至PEPS
					if(!SetCanInitial("PEPS1",canid))return;
				}else if(i == 80){
					if(!SetCanInitial("PEPS1",canid)) return;
					if (cartype.getMap("TCM") >= 1 || cartype.getMap("TCU") >= 1){
						i = 88;
						continue;
					}
				}
				else if(i == 6 || i == 13 || i == 28 || i == 93){ //安全认证1
					if(seed[0] == 0) continue;
					Security.CX62_IMMO_Safekey(seed, key,0);
					System.arraycopy(key, 0, cmd, 3, 8);
				}else if (i == 7){
					//System.arraycopy(cartype.peps, 0, cmd, 4, 3);
				}else if(i == 20 || i == 34 || i == 38 || i == 50 || i == 61 || i == 73 || i == 84){ //安全认证2
					if(seed[0] == 0) continue;
					int pin=(cartype.pin[0]&0xFF) * 0x1000000 + (cartype.pin[1]&0xFF) * 0x10000 +
							(cartype.pin[2]&0xFF) * 0x100 + (cartype.pin[3]&0xFF) * 0x01;
					Security.CX62_IMMO_Safekey(seed, key,pin);
					System.arraycopy(key, 0, cmd, 3, 8);
				}else if(i == 14 || i == 29){ //写VIN
					System.arraycopy(cartype.vin, 0, cmd, 4, 17);
				}else if(i == 16){ //IMMO写PIN
					if((v_immo_status[1] & 0x04) == 0x04){ //VIN、PIN已写
						continue;
					}
					System.arraycopy(cartype.pin, 0, cmd, 4, 4);
				}else if(i == 31){ //EMS写PIN
					if(((v_ems_status[1] >> 2) & 0x01) == 0x01)continue;
					System.arraycopy(cartype.pin, 0, cmd, 4, 4);
				}else if(i == 47){ //提示更换第二把钥匙
					for(int kk = bcm_time; kk >= 0; kk --){
						showTip("更换钥匙2..."+kk+"s");
						Commonfunc.sleep(1000);
					}
				}else if (i == 48 || i == 59){
					if((v_trans_status[0] & 0x01) != 0x01){ //防盗线圈故障
						break;
					}
				}else if(i == 58){ //提示更换第3把钥匙
					if((cartype.byteConfig[4]&0x40)==0|| key_num == 3){//没有BM则不学习第三把钥匙
						i = 66 ;
						continue;
					}
					bcm_time = 6;
					for(int kk = bcm_time; kk >= 0; kk --){
						showTip("更换钥匙3..."+kk+"s");
						Commonfunc.sleep(1000);
						if((kk % 2) == 0){
//							bluetooth.canSendAndRecvN2N(keep, readbuf, Common.CMD_MAX_TIME);
							m_com.CanSendOneOnly(canid[0],keep,keep.length);
						}
					}
				}else if(i == 24 || i == 54 || i == 64){
					Commonfunc.sleep(1500);
				}

//				error = bluetooth.canSendAndRecvN2N(cmd, readbuf, Common.CMD_MAX_TIME);
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				if(error == 5001){
					if(i == 1  && !veleo){
						veleo = true;
						i--;
					}
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}
				else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					if(i == 1  && !veleo){
						veleo = true;
						i--;
					}
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if(i == 1  && !veleo){
						veleo = true;
						i--;
					}
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}

				if(i == 1){//KEY ON,后等待10秒
					if(((readbuf[4] >> 3) & 0x01) == 0x01){ //ON		//
						for(int k = 2; k >= 0; k --){
							showTip("KEY ON  等待" + k + "s");
							Commonfunc.sleep(1000);
						}
					}else{
						showTip("请打开钥匙...");
						Commonfunc.sleep(1000);
						i --;
					}
				}else if(i == 8){
					Commonfunc.sleep(2000);
				}else if(i == 10){	//读IMMO状态
					System.arraycopy(readbuf, 4,v_immo_status,0,4);
					if((v_immo_status[0] & 0x01) != 0x01){ //keyon
						showTip("请打开钥匙...");
						Commonfunc.sleep(500);
						i --;
						continue;
					}
					if((v_immo_status[1]) != 0){
						showProcessList("IMMO已学过",Common.NULL,Common.OK);
					}
					String status;
					if(((v_immo_status[1] >> 1) & 0x01) == 0x01) //VIN已写
						status="VIN:1;";
					else
						status="VIN:0;";
					if(((v_immo_status[1] >> 2) & 0x01) == 0x01) //VIN已写
						status+="PIN:1;";
					else
						status+="PIN:0;";
					int nu = (v_immo_status[1] >> 3) & 0x07;
					status+="KEY:"+nu;
					showProcessList(status,Common.NULL,Common.OK);
				}else if(i == 17){ //读取钥匙数量
					System.arraycopy(readbuf, 4,v_immo_status,0,4);
					key_num = (v_immo_status[1] >> 3) & 0x07; //关联的钥匙数量
					if(key_num > 0){
						showProcessList(key_num+"把",Common.NULL,Common.OK);
						i = 24;
						continue;
					}
				}else if(i == 11 || i == 47 || i == 58){ //读转发器状态
					System.arraycopy(readbuf, 4,v_trans_status,0,4);
					int Result = 1;
					String status;
					if((v_trans_status[0] & 0x01) == 0x01) //防盗线圈故障
						status="Ring:1;";
					else{
						status="Ring:0;";
						Result = 2;
					}
					if(((v_trans_status[0] >> 3) & 0x01) == 0x01) //new
						status+="New:0;";
					else
						status+="New:1;";
					if(((v_trans_status[0] >> 4) & 0x01) == 0x01) //SK
						status+="SK:1;";
					else
						status+="SK:0;";
					showProcessList(status,Common.NULL,Result == 2 ? Common.NG : Common.OK);
				}else if(i == 5 || i == 12 || i == 19 || i == 27 || i == 33 || i == 37 || i == 49 || i == 60  || i == 72 || i == 83 || i == 92){ //获取SEED
					System.arraycopy(readbuf, 3,seed,0,8);
				}else if(i == 15 || i == 30){ //读VIN,显示
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					showProcessList(new String(vin),new String(vin),Common.OK);
				}else if(i == 21 || i == 39 || i == 51 || i == 62 || i == 74 || i == 85){ //学习钥匙
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1500);
				}else if(i == 22 || i == 40 || i == 52 || i == 63 || i == 75 || i  == 86){ //15检查钥匙学习结果,33检查EMS学习SK情况,45key2,63tcu,68 immo teach tcu,77immo teach escl
					if(readbuf[5] == 0x01 || readbuf[5] == 0x03){ //继续
						if(i == 63) continue;
						Commonfunc.sleep(500);
						i --;
					}else if(readbuf[5] == 0x02) {//OK
						showProcessList("OK",Common.NULL,Common.OK);
					}else if(readbuf[5] == 0x04){ //stop
						showProcessList("Routine stopped!",Common.NULL,Common.NG);
						break;
					}else{	//stop
						showProcessList("Routine failure and routine not run!",Common.NULL,Common.NG);
						break;
					}
				}else if(i == 24){ //检查转发器状态
					System.arraycopy(readbuf, 4,v_trans_status,0,4);
					if((v_trans_status[0] & 0x10) == 0x10) //已经配对
						showProcessList("",Common.NULL,Common.OK);
					else{
						showProcessList(readbuf[5]+"",Common.NULL,Common.NG);
					}
				}else if(i == 26 || i == 32){ //读取EMS状态
					System.arraycopy(readbuf, 4,v_ems_status,0,4);
					String status;
					if(((v_ems_status[1] >> 1) & 0x01) == 0x01) //VIN
						status="VIN:1;";
					else
						status="VIN:0;";
					if(((v_ems_status[1] >> 2) & 0x01) == 0x01) //PIN
						status+="PIN:1;";
					else
						status+="PIN:0;";
					if(((v_ems_status[1] >> 3) & 0x01) == 0x01) //SK
						status+="SK:1;";
					else
						status+="SK:0;";
					showProcessList(status,Common.NULL,Common.OK);
					if(i == 32){
						if(((v_ems_status[1] >> 1) & 0x07) == 0x07){ //EMS已经学习过
							i = 43;
							continue;
						}
					}
				}else if(i == 43){ //EMS状态,SK学习结果
					System.arraycopy(readbuf, 4,v_ems_status,0,4);
					if(((v_ems_status[1] >> 1) & 0x07) == 0x07) //EMS已经学习过
						showProcessList("VIN/PIN/SK",Common.NULL,Common.OK);
					else{
						showProcessList("SK",Common.NULL,Common.NG);
					}
				}else if(i == 45){ //key off
					System.arraycopy(readbuf, 4,v_immo_status,0,4);//第3次01 08
					if((v_immo_status[0] & 0x01) == 0x01){ //ON
						showTip("KEY OFF...");
						Commonfunc.sleep(1000);
						i --;continue;
					}
					int nu = (v_immo_status[1] >> 3) & 0x07; //关联的钥匙数量
					if(nu > 1){
						i = 54;
						continue;
					}

				}else if(i == 82){ //key off
					System.arraycopy(readbuf, 4,v_immo_status,0,4);
					if((v_immo_status[0] & 0x01) == 0x01){ //ON
						showTip("切换至ACC档...");
						Commonfunc.sleep(500);
						i --;
					}
				}else if(i == 90){//KEY ON
					System.arraycopy(readbuf, 4,v_immo_status,0,4);
					if((v_immo_status[0] & 0x01) == 0x00){ //0FF
						showTip("开钥匙KEY ON...");
						Commonfunc.sleep(500);
						i --;
					}else{ //等10秒
						for(int k = 2; k >= 0; k --){
							showTip("等待:"+k+"s");
							Commonfunc.sleep(1000);
						}
					}
				}else if(i == 67){ //检查钥匙数量
					System.arraycopy(readbuf, 4,v_immo_status,0,4);
					key_num = (v_immo_status[1] >> 3) & 0x07; //关联的钥匙数量
					boolean v_isc =false;
					if(cartype.getMap("BM")>0)
						v_isc = true;
					if(key_num == 2){ //OK
						showProcessList("2把",Common.NULL,Common.OK);
					}else if(key_num == 3 && v_isc){ //OK
						showProcessList("3把",Common.NULL,Common.OK);
					}else{
						showProcessList(key_num+"把",Common.NULL,Common.NG);
						break;
					}
				}else if(i == 55|| i == 65 || i == 79){ //EMS\IMMO ClearDTC
					showProcessList("",Common.NULL,Common.OK);
					if(i == 79) {//TCU做完退出
						i = 90;
						continue;
					}
				}else if(i == 78){ //检查TCU状态结果
					System.arraycopy(readbuf, 4,v_tcu_status,0,3);
					if(v_tcu_status[0] != 0x0F){ //不OK
						showProcessList(("TCU authentication failure!"),Common.NULL,Common.NG);
					}else
						showProcessList(("TCU OK!"),Common.NULL,Common.OK);
				}else if(i == 82){ //ESCL学习结果
					System.arraycopy(readbuf, 4,v_escl_status,0,1);
					if(v_escl_status[0] != 0x00){ //不OK
						showProcessList("ESCL 已经学习过!",Common.NULL,Common.OK);
						i = 88;
						continue;
					}else
						showProcessList("TSCL 开始学习!",Common.NULL,Common.OK);
				}else if(i == 88){//ESCL学习结果
					System.arraycopy(readbuf, 4,v_escl_status,0,1);
					if(v_escl_status[0] != 0x01){ //不OK
						showProcessList("ESCL authentication failure",Common.NULL,Common.NG);
					}else
						showProcessList("TSCL OK!",Common.NULL,Common.OK);
				}else if(i == 95){ //学习结果
					if(readbuf[5] == 0x01 || readbuf[5] == 0x03){ //继续
						i --;
						Commonfunc.sleep(1000);
					}else if(readbuf[5] == 0x02)
						showProcessList("OK",Common.NULL,Common.OK);
					else{
						showProcessList("执行失败",Common.NULL,Common.OK);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}else if(stepType.substring(0, 3).equals("SHW")){ //SHW
				//handlerSHW(stepType, true);
			}
		}
	}


	private void fun_JX65_Ems1788(Profile.Section Pstep,String Pname)
	{
		int num = Integer.valueOf(Pstep.get("NUM"));
		stepId = Integer.valueOf(Pstep.get("MODULE_ID"));
		String Pmodule = Pstep.get("MODULE");
		String step_t = null;
		String step_name = null;
		byte [] Readbuf = new byte[512];
		byte [] seed = new byte[10];
		byte [] key = new byte[10];
		int v_maxlen = 0;
		short v_crc = (short) 0xFFFF;
		int [] canid = new int[2];
		if (Common.Communication==0) {
			if(!SetCanInitial(Pmodule,canid)) {
				showProcessList("设置通讯盒",Common.NULL, Common.NG);
				return;
			}
			SetCanInitTimer(0);
			SetCanMode(1,500000);
		}else {
			if(!m_com.SetCanBaud(500000))
			{
				showProcessList("设置波特率",Common.NULL,Common.NG);
				return;
			}
			if(!m_com.SetCanMode(2))
			{
				showProcessList("设置CanMode",Common.NULL,Common.NG);
				return;
			}
			if(!m_com.SetCommunTimer(5, 1000, 5000, 0))
			{
				showProcessList("设置时序",Common.NULL,Common.NG);
				return;
			}
			Can can = cartype.getCan(Pstep.get("MODULE"));
			canid[0] = can.getSendid();
			canid[1] = can.getRecvid();
		}
		//SetCanInitTimer(0);
		//先解析刷写数据
		String v_app_file = "";
		String v_dri_file = "";
		byte [] appbuf = null;
		//int v_applen = 0;
		byte [] dribuf = null;
		//int v_drilen = 0;
		int v_drilength = 0;
		int v_applength = 0;
		int v_down_block = 0; //已经下载的块数
		int v_down_length = 0;
		int v_app_down = 0;
		//driver
		int v_dri_down_block = 0;
		int v_dri_down_length = 0;
		int v_dri_down = 0;
		short v_calc = 0;
		byte [] cmd_link = {0x02,0x3e,(byte) 0x80};
		int error = 0;
		for(int i = 1; i < (num + 1); i ++)
		{
			//Pid += 1;
			step_t = Pstep.get("T" + i);
			stepName = Pstep.get("T" + i + "_NAME");
			if(step_t == null) break;
			if(step_t.length() < 3) continue;
			if(step_t.substring(0, 3).equals("CMD"))  //cmd
			{
				//获取cmd长度
				int cmdlen = Commonfunc.HexStringtoInt(step_t.substring(4, 6)) + 1;
				byte [] cmd = new byte[cmdlen];
				if(Commonfunc.CmdStringToBytes(step_t.substring(4), cmd, cmdlen) != cmd.length) return;
				showTip(step_name + "...");
				//---------------------发送前处理---------------------
				//解析下载文件
				if(i == 1)
				{
					//先解析driver文件
					showTip("解析Driver文件...");
					if(cartype.ems == null)
					{
						showProcessList("解析EMS文件","Mes推送数据为空",Common.NG);
						return;
					}
					else
					{
						v_dri_file = cartype.flashDirectory +  "EMS/" +  "flashdrive.bin";
						int ems_a = cartype.ems.indexOf("*", 20);
						if(ems_a > 0)
						{
							int ems_b = cartype.ems.indexOf("*", ems_a + 2);
							String ems_name = cartype.ems.substring(ems_a + 1, ems_b);
							v_app_file = cartype.flashDirectory+  "EMS/" + ems_name  + ".bin";
						}
					}
					if((v_dri_file != null) && (v_dri_file.length() > 15))
					{
						try {
							v_drilength  = Commonfunc.GetBinFileLength(v_dri_file);
							//v_drilength = Commonfunc.GetHexFileLength(v_dri_file, v_dri_adr, (long) 0);;
							dribuf = new byte[v_drilength + 10];
							//v_drilength = Commonfunc.ReadHexFile(v_dri_file,dribuf, v_dri_block, (long) 0);
							v_drilength = Commonfunc.ReadBinFile(v_dri_file, dribuf);
						} catch (IOException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
						if(v_drilength != 16)
						{
							m_com.m_log.PrintLog("Open File Fialed:" + v_dri_file);
							showProcessList("Driver数据解析",v_dri_file,Common.NG);
							break;
						}
					}
					showTip("解析app文件...");
					try {
						//v_applength = Commonfunc.GetHexFileLength(v_app_file, v_app_adr, (long) 0);
						v_applength = Commonfunc.GetBinFileLength(v_app_file);
						appbuf = new byte[v_applength + 10];
						//v_applength = Commonfunc.ReadHexFile(v_app_file, appbuf, v_app_block, (long) 0);
						v_applength = Commonfunc.ReadBinFile(v_app_file, appbuf);
						//v_applength = 0x240000;  //特殊处理
						v_down_length = v_applength;
						if(v_down_length != 0x180000)
						{
							showProcessList("App数据解析",v_app_file,Common.NG);
							break;
						}
						//v_calc = Commonfunc.me1781_CalcCRC16(appbuf, 0, v_applength);
					} catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					if(v_applength < 100)
					{
						m_com.m_log.PrintLog("Open File Fialed:" + v_app_file);
						showProcessList("App数据解析",v_app_file,Common.NG);
						break;
					}
				}
				else if(cmd[1] == 0x27 && cmd[2] == 0x04) //安全认证
				{
					if((seed[0] | seed[1] | seed[2] | seed[3]) == 0) continue;
					//EolFunction.Changan_SafeCode_level(seed,key,0x61E47D07);
					Security.CX62_IMMO_Safekey(seed, key,0);
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				}
				else if(cmd[1] == 0x2E) //写
				{
					int v_code = (cmd[2]&0xFF) * 0x100 + (cmd[3]&0xFF);
					switch(v_code)
					{
						case 0xF199:
							System.arraycopy(Common.cartype.time, 0, cmd, 4, cmd[0] - 3);
							break;
					}
				}
				else if(i == 9) //下载驱动
				{
					//拷贝数据
					System.arraycopy(dribuf, 0, cmd, 3, v_drilength);
				}
				else if(i == 18) //下载数据区1
				{
					byte [] cmd_down = new byte[v_maxlen + 2];
					int v_len = 0;
					int v_start = 0;
					int v_frame = 1;
					int v_adr = 0xC000;
					v_down_length = 0x4000;
					v_app_down = 0;
					while(v_app_down < v_down_length)
					{
						if((v_app_down + v_maxlen - 2) >= v_down_length) //last
						{
							v_len = v_down_length - v_app_down;
						}
						else
						{
							v_len = v_maxlen - 2;
						}
						if((v_len + 2) >= 0x100)
						{
							v_start = 1;
							cmd_down[0] = (byte) ((v_len + 2) / 0x100);
						}
						else
							v_start = 0;
						//拷贝数据
						cmd_down[v_start ++] = (byte) ((v_len + 2) % 0x100);
						cmd_down[v_start ++] = 0x36;
						cmd_down[v_start ++] = (byte)(v_frame ++);
						System.arraycopy(appbuf,v_adr +  v_app_down, cmd_down, v_start, v_len);

						error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd_down,v_len+v_start, Readbuf, 5003, Common.CMD_MAX_TIME * 3, 1);
						if((error > 100) || ((Readbuf[1]&0xFF) == 0x7F))//异常
						{
							break;
						}
						Sleep(5);
						m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
						v_app_down += v_len;
						showTip("下载数据区1:" + v_applength + "\\" +  v_app_down);
					}
					v_down_block ++;
				}
				else if(i == 21) //下载数据区2
				{
					byte [] cmd_down = new byte[v_maxlen + 2];
					int v_len = 0;
					int v_start = 0;
					int v_frame = 1;
					int v_adr = 0x20000;
					v_down_length = 0x160000;
					v_app_down = 0;
					while(v_app_down < v_down_length)
					{
						if((v_app_down + v_maxlen - 2) >= v_down_length) //last
						{
							v_len = v_down_length - v_app_down;
						}
						else
						{
							v_len = v_maxlen - 2;
						}
						if((v_len + 2) >= 0x100)
						{
							v_start = 1;
							cmd_down[0] = (byte) ((v_len + 2) / 0x100);
						}
						else
							v_start = 0;
						//拷贝数据
						cmd_down[v_start ++] = (byte) ((v_len + 2) % 0x100);
						cmd_down[v_start ++] = 0x36;
						cmd_down[v_start ++] = (byte)(v_frame ++);
						System.arraycopy(appbuf,v_adr +  v_app_down, cmd_down, v_start, v_len);

						error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd_down,v_len+v_start, Readbuf, 5003, Common.CMD_MAX_TIME * 3, 1);
						if((error > 100) || ((Readbuf[1]&0xFF) == 0x7F))//异常
						{
							break;
						}
						Sleep(5);
						m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
						v_app_down += v_len;
						showTip("下载数据区2:" + v_applength + "\\" +  v_app_down);
					}
					v_down_block ++;
				}
				else if(i == 23)
				{
					v_calc = Commonfunc.me1781_CalcCRC16(appbuf, 0xC000, 0x4000,(short)0xffff);
					cmd[13] = (byte) ((v_calc >> 8) & 0xFF);
					cmd[14] = (byte) (v_calc & 0xFF);
				}
				else if(i == 26)
				{
					v_calc = Commonfunc.me1781_CalcCRC16(appbuf, 0x20000, 0x160000,(short)0xffff);
					cmd[13] = (byte) ((v_calc >> 8) & 0xFF);
					cmd[14] = (byte) (v_calc & 0xFF);
				}
				else if(i == 29)
				{
					v_calc = Commonfunc.me1781_CalcCRC16(appbuf, 0xC000, 0x4000,(short)0xffff);
					v_calc = Commonfunc.me1781_CalcCRC16(appbuf, 0x20000, 0x160000,v_calc);
					cmd[5] = (byte) ((v_calc >> 8) & 0xFF);
					cmd[6] = (byte) (v_calc & 0xFF);
				}

				//特殊处理多次发送命令
				if(i == 18 || i == 21)
				{

				}
				else if(i == 1 || i == 2 || i == 3)
				{
					error = m_com.CanSendOneOnly(0x7DF, cmd, cmdlen);
					Sleep(Common.waittime);
					continue;
				}
				else //普通发送命令
				{
					error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmdlen, Readbuf, 5003, Common.CMD_MAX_TIME * 2, 3);
					Sleep(50);
					m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
				}
				Sleep(Common.waittime);
				//错误处理
				if(error == 5001) //通讯超时
				{
					if(i > 8)
					{
						showProcessList("通讯超时!",Common.NULL,Common.NG);
						break;
					}
					else
						continue;
				}
				else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					if(i > 8)
					{
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
						return;
					}
					else
						continue;
				}
				else if(error < 100) //异常回复
				{
					if(i < 5) continue;
					if((Readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
						break;
					}
				}
				//特殊处理返回结果
				if(i == 34 || i == 35 || i == 36)
				{
					byte [] v_soft = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf, 4, v_soft, 0, Readbuf[0] - 3);
					String v_softver = new String(v_soft);
					showProcessList(v_softver,Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x62) //读数据
				{
					byte [] v_data = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf, 4, v_data, 0, Readbuf[0] - 3);
					String v_show = "";
					String v_get = "";
					int v_code = (Readbuf[2]&0xFF) * 0x100 + (Readbuf[3]&0xFF);
					switch(v_code)
					{
						case 0xF190:
							v_show = new String(v_data);
							v_get = new String(Common.cartype.vin);
							break;
						case 0xF187:
							v_show = new String(v_data);
							v_show = v_show.replace(" ", "");
							v_show = v_show.trim();
							v_get = "";
							break;
						case 0xF18A:
							v_show = new String(v_data);
							v_get = "";
							break;
					}
					v_show = v_show.replace(" ", "");
					v_show = v_show.trim();
					if(v_get.length() > 0)
					{
						if(v_show.equals(v_get))
							showProcessList(v_show,v_get,Common.OK);
						else if(Common.cartype.OptMode == 1)
							showProcessList(v_show , v_get,Common.NULL);
						else
						{
							showProcessList(v_show, v_get,Common.NG);
							break;
						}
					}
					else
					{

						showProcessList(v_show,Common.NULL,Common.NULL);
					}
				}
				else if(i == 10 || i == 19 || i == 22) //结束下载driver
				{
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x54) //清故障码
				{
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x59) //读故障码
				{
					//处理故障码
					byte [] dtc = new byte[256];
					dtc[0] = (byte) (((Readbuf[0]&0xFF) - 3) / 4);
					System.arraycopy(Readbuf, 4, dtc, 1, Readbuf[0] - 3);
					ArrayList<Map<String,String>> dtclist = new ArrayList<Map<String,String>>();
					showProcessList("无故障",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x67 && Readbuf[2] == 0x03) //seed
				{
					System.arraycopy(Readbuf, 3, seed, 0, Readbuf[0] - 2);
				}
				else if(Readbuf[1] == 0x74)
				{
					v_maxlen = (Readbuf[3]& 0xFF) * 0x100 + (Readbuf[4]& 0xFF);
				}
				else if(Readbuf[1] == 0x51)
				{
					Sleep(1000);
					showProcessList( "",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x71 && Readbuf[2] == 0x03 )
				{
					if(Readbuf[5] == 0x03)
					{
						i --;
						Sleep(1000);
					}
					else if(Readbuf[5] == 0x02)
					{
						showProcessList("","",Common.OK);
					}
					else
					{
						showProcessList("" + (Readbuf[5] & 0xFF),Common.NULL,Common.NG);
						break;
					}
				}
				else if(Readbuf[1] == 0x71 && Readbuf[2] == 0x01)
				{
					showProcessList("","",Common.OK);
					Sleep(1000);
				}
				else if(Readbuf[1] == 0x51)
				{
					showProcessList("","",Common.OK);
					Sleep(1000);
				}
			}
		}
	}
	private void fun_KM23_PEPS1(Section section){
		if(!getpin()){
			showProcessList("未获取到PIN或配置码",Common.NULL,Common.NG);
			return;
		}
		byte [] v_peps_status =new byte[10];	//ESCL状态
		byte [] v_escl_status =new byte[10];	//ESCL状态
		byte [] v_tcu_status = new byte[10];	//TCU状态
		byte [] v_immo_status =new byte[10];	//IMMO状态
		byte [] v_ems_status = new byte[10];	//EMS状态
		byte [] v_trans_status = new byte[10];	//转发器状态
		int bcm_time = 6;
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				//---------------------发送前处理---------------------
				if(i == 1){		//切换至IMMO
					if(!SetCanInitial("BCM1",canid)) return;
				}else if(i == 9 || i == 36 || i == 44 || i == 71|| i == 81 || i == 89){		//切换至IMMO
					if(!SetCanInitial("IMMO1",canid)) return;
				}else if(i == 25 || i == 42){	//切换至EMS
					if(!SetCanInitial("EMS1",canid)) return;
				}else if(i == 59 || i == 77){ //切换至TCU
					if(!SetCanInitial("TCU1",canid))return;
				}else if(i == 2 || i == 58 || i == 88 || i == 91){ //切换至PEPS
					if(!SetCanInitial("PEPS1",canid))return;
				}else if(i == 6 || i == 13 || i == 28 || i == 93){ //安全认证1
					if(seed[0] == 0) continue;
					Security.CX62_IMMO_Safekey(seed, key,0);
					System.arraycopy(key, 0, cmd, 3, 8);
				}else if (i == 7){
					System.arraycopy(cartype.peps, 0, cmd, 4, 3);
				}else if(i == 20 || i == 34 || i == 38 || i == 50 || i == 73 || i == 84){ //安全认证2
					if(seed[0] == 0) continue;
					int pin=(cartype.pin[0]&0xFF) * 0x1000000 + (cartype.pin[1]&0xFF) * 0x10000 +
							(cartype.pin[2]&0xFF) * 0x100 + (cartype.pin[3]&0xFF) * 0x01;
					Security.CX62_IMMO_Safekey(seed, key,pin);
					System.arraycopy(key, 0, cmd, 3, 8);
				}else if(i == 63 || i== 68){ //TCU Safekey3
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}else if(i == 66){ //TCU写PIN码
					if((v_tcu_status[0] & 0x04) == 0x04)  continue;//VIN、PIN已写
					System.arraycopy(cartype.pin, 0, cmd, 4, 4);
				}else if(i == 14 || i == 29 || i == 64){ //写VIN
					System.arraycopy(cartype.vin, 0, cmd, 4, 17);
				}else if(i == 16){ //IMMO写PIN
					if((v_immo_status[1] & 0x04) == 0x04) continue; //VIN、PIN已写
					System.arraycopy(cartype.pin, 0, cmd, 4, 4);
				}else if(i == 21 || i == 22 || i == 23 || i == 51 || i == 52 || i == 53){ //学习钥匙1\2
					if(((v_trans_status[0] >> 3) & 0x07) == 0x07) //已经配对
						continue;
					else if(((v_trans_status[0] >> 3) & 0x01) == 0x01) //old
						cmd[4] = 0x01;
				}else if(i == 31){ //EMS写PIN
					if(((v_ems_status[1] >> 2) & 0x01) == 0x01) continue;
					System.arraycopy(cartype.pin, 0, cmd, 4, 4);
				}else if(i == 47){ //提示更换第二把钥匙
					for(int kk = bcm_time; kk >= 0; kk --){
						showTip("更换钥匙2.."+kk+"s");
						Commonfunc.sleep(1000);
					}
				}else if(i == 24 || i == 54){
					Commonfunc.sleep(1500);
				}else if (i == 48 || i == 59){
					if((v_trans_status[0] & 0x01) != 0x01){ //防盗线圈故障
						break;
					}
				}

//				error = bluetooth.canSendAndRecvN2N(cmd, readbuf, Common.CMD_MAX_TIME);
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);

				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}

				if(i == 1){//KEY ON,后等待10秒
					if(((readbuf[4] >> 3) & 0x01) == 0x01){ //ON		//
						for(int k = 4; k >= 0; k --){
							showTip("KEY ON  等待"+k+"s");
							Commonfunc.sleep(1000);
						}
					}else{
						showTip("请打开钥匙...");
						Commonfunc.sleep(1000);
						i --;
					}
				}else if(i == 8){
					Commonfunc.sleep(2000);
				}else if(i == 10){	//读IMMO状态
					System.arraycopy(readbuf, 4,v_immo_status,0,4);
					if((v_immo_status[0] & 0x01) != 0x01){ //keyon
						showTip("请打开钥匙...");
						Commonfunc.sleep(500);
						i --;
						continue;
					}
					if((v_immo_status[1]) != 0){
						showProcessList("IMMO已学过",Common.NULL,Common.OK);
					}
					String status;
					if(((v_immo_status[1] >> 1) & 0x01) == 0x01) //VIN已写
						status="VIN:1;";
					else
						status="VIN:0;";
					if(((v_immo_status[1] >> 2) & 0x01) == 0x01) //VIN已写
						status+="PIN:1;";
					else
						status+="PIN:0;";
					int nu = (v_immo_status[1] >> 3) & 0x07;
					status+="KEY:"+nu;
					showProcessList(status,Common.NULL,Common.OK);
				}else if(i == 17){ //读取钥匙数量
					System.arraycopy(readbuf, 4,v_immo_status,0,4);
					key_num = (v_immo_status[1] >> 3) & 0x07; //关联的钥匙数量
					if(key_num > 0){
						showProcessList(key_num + "把",Common.NULL,Common.OK);
						i = 24;
						continue;
					}
				}else if(i == 11 || i == 47){ //读转发器状态
					System.arraycopy(readbuf, 4,v_trans_status,0,4);
					int Result = 1;
					String status;
					if((v_trans_status[0] & 0x01) == 0x01) //防盗线圈故障
						status="Ring:1;";
					else{
						status="Ring:0;";
						Result = 2;
					}
					if(((v_trans_status[0] >> 3) & 0x01) == 0x01) //new
						status+="New:0;";
					else
						status+="New:1;";
					if(((v_trans_status[0] >> 4) & 0x01) == 0x01) //SK
						status+="SK:1;";
					else
						status+="SK:0;";
					showProcessList(status,Common.NULL,Result == 2 ? Common.NG : Common.OK);
				}else if(i == 5 || i == 12 || i == 19 || i == 27 || i == 33 || i == 37 || i == 49 || i == 62 || i == 67  || i == 72 || i == 83 || i == 92){ //获取SEED
					System.arraycopy(readbuf, 3,seed,0,8);
				}else if(i == 15 || i == 30 || i == 65){ //读VIN,显示
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					showProcessList(new String(vin),new String(vin),Common.OK);
				}else if(i == 21 || i == 39 || i == 51 || i == 69 || i == 74 || i == 85){ //学习钥匙
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(2500);
				}else if(i == 22 || i == 40 || i == 52 || i == 70 || i == 75 || i  == 86){ //15检查钥匙学习结果,33检查EMS学习SK情况,45key2,63tcu,68 immo teach tcu,77immo teach escl
					if(readbuf[5] == 0x01 || readbuf[5] == 0x03){ //继续
						if(i == 63) continue;
						Commonfunc.sleep(500);
						i --;
					}else if(readbuf[5] == 0x02) {//OK
						showProcessList("OK",Common.NULL,Common.OK);
					}else if(readbuf[5] == 0x04){ //stop
						showProcessList("Routine stopped!",Common.NULL,Common.NG);
						break;
					}else{	//stop
						showProcessList("Routine failure and routine not run!",Common.NULL,Common.NG);
						break;
					}
				}else if(i == 24){ //检查转发器状态
					System.arraycopy(readbuf, 4,v_trans_status,0,4);
					if((v_trans_status[0] & 0x10) == 0x10) //已经配对
						showProcessList("",Common.NULL,Common.OK);
					else{
						showProcessList(readbuf[5]+"",Common.NULL,Common.NG);
					}
				}else if(i == 26 || i == 32){ //读取EMS状态
					System.arraycopy(readbuf, 4,v_ems_status,0,4);
					String status;
					if(((v_ems_status[1] >> 1) & 0x01) == 0x01) //VIN
						status="VIN:1;";
					else
						status="VIN:0;";
					if(((v_ems_status[1] >> 2) & 0x01) == 0x01) //PIN
						status+="PIN:1;";
					else
						status+="PIN:0;";
					if(((v_ems_status[1] >> 3) & 0x01) == 0x01) //SK
						status+="SK:1;";
					else
						status+="SK:0;";
					showProcessList(status,Common.NULL,Common.OK);
					if(i == 32){
						if(((v_ems_status[1] >> 1) & 0x07) == 0x07){ //EMS已经学习过
							i = 43;
							continue;
						}
					}
				}else if(i == 43){ //EMS状态,SK学习结果
					System.arraycopy(readbuf, 4,v_ems_status,0,4);
					if(((v_ems_status[1] >> 1) & 0x07) == 0x07) //EMS已经学习过
						showProcessList("VIN/PIN/SK",Common.NULL,Common.OK);
					else{
						showProcessList("SK",Common.NULL,Common.NG);
					}
				}else if(i == 45){ //key off
					System.arraycopy(readbuf, 4,v_immo_status,0,4);//第3次01 08
					int nu = (v_immo_status[1] >> 3) & 0x07; //关联的钥匙数量
					if(nu > 1){
						i = 54;
						continue;
					}
					if((v_immo_status[0] & 0x01) == 0x01){ //ON
						showTip("KEY OFF...");
						Commonfunc.sleep(100);
						i --;
					}
				}else if(i == 46){ //检查KEY ON
					System.arraycopy(readbuf, 4,v_immo_status,0,4);//第四次
					if((v_immo_status[0] & 0x01) == 0x00){ //ON
						showTip("KEY ON...");
						Commonfunc.sleep(100);
						i --;
					}
				}else if(i == 82){ //key off
					System.arraycopy(readbuf, 4,v_immo_status,0,4);
					if((v_immo_status[0] & 0x01) == 0x01){ //ON
						showTip("切换至ACC档...");
						Commonfunc.sleep(500);
						i --;
					}
				}else if(i == 90){//KEY ON
					System.arraycopy(readbuf, 4,v_immo_status,0,4);
					if((v_immo_status[0] & 0x01) == 0x00){ //0FF
						showTip("开钥匙KEY ON...");
						Commonfunc.sleep(500);
						i --;
					}else{ //等10秒
						for(int k = 2; k >= 0; k --){
							showTip("等待:"+k+"s");
							Commonfunc.sleep(1000);
						}
					}
				}else if(i == 67){ //检查钥匙数量
					System.arraycopy(readbuf, 4,v_immo_status,0,4);
					key_num = (v_immo_status[1] >> 3) & 0x07; //关联的钥匙数量
					boolean v_isc =false;
					if(cartype.getMap("BM")>0)
						v_isc = true;
					if(key_num == 2){ //OK
						showProcessList("2把",Common.NULL,Common.OK);
					}else if(key_num == 3 && v_isc){ //OK
						showProcessList("3把",Common.NULL,Common.OK);
					}else{
						showProcessList(key_num+"把",Common.NULL,Common.NG);
						break;
					}
				}else if(i == 54){ //检查钥匙数量
					System.arraycopy(readbuf, 4,v_immo_status,0,4);
					key_num = (v_immo_status[1] >> 3) & 0x07; //关联的钥匙数量
					if( key_num == 2){
						showProcessList("2把",Common.NULL,Common.OK);
					}else{
						showProcessList(key_num + "把",Common.NULL,Common.NG);
						break;
					}
				}else if(i == 55 || i == 79){ //EMS\IMMO ClearDTC
					showProcessList("",Common.NULL,Common.OK);
					if(i == 79) {//TCU做完退出
						i = 90;
						continue;
					}
				}else if(i == 58){ //检查PEPS状态
					System.arraycopy(readbuf, 4,v_peps_status,0,2);
					if((v_peps_status[0] & 0x04) == 0x04){
						showProcessList("TCU study",Common.NULL,Common.OK);
					}else{  //ESCL
						i = 79;
						showProcessList("ESCL study",Common.NULL,Common.OK);
					}
				}else if(i == 59){ //检查TCU状态
					System.arraycopy(readbuf, 4, v_tcu_status,0,3);
					if(v_tcu_status[0] == 0x0F){ //已经匹配完成
						showProcessList("PIN\\VIN\\SK",Common.NULL,Common.OK);
						i = 78;
						continue;
					}else if((v_tcu_status[0] & 0x01) == 0x01){ //不是新的
						showProcessList("TCU not in delivery",Common.NULL,Common.OK);
					}else{
						showProcessList("TCU in delivery",Common.NULL,Common.OK);
					}
				}else if(i == 61){
					System.arraycopy(readbuf, 4, v_tcu_status,0,3);
				}else if(i == 78){ //检查TCU状态结果
					System.arraycopy(readbuf, 4,v_tcu_status,0,3);
					if(v_tcu_status[0] != 0x0F){ //不OK
						showProcessList(("TCU authentication failure!"),Common.NULL,Common.NG);
					}else
						showProcessList(("TCU OK!"),Common.NULL,Common.OK);
				}else if(i == 80){ //ESCL学习结果
					System.arraycopy(readbuf, 4,v_escl_status,0,1);
					if(v_escl_status[0] != 0x00){ //不OK
						showProcessList("ESCL 已经学习过!",Common.NULL,Common.OK);
						i = 90;
						continue;
					}else
						showProcessList("ESCL 开始学习!",Common.NULL,Common.OK);
				}else if(i == 88){//ESCL学习结果
					System.arraycopy(readbuf, 4,v_escl_status,0,1);
					if(v_escl_status[0] != 0x01){ //不OK
						showProcessList("ESCL authentication failure",Common.NULL,Common.NG);
					}else
						showProcessList("ESCL OK!",Common.NULL,Common.OK);
				}else if(i == 95){ //学习结果
					if(readbuf[5] == 0x01 || readbuf[5] == 0x03){ //继续
						i --;
						Commonfunc.sleep(1000);
					}else if(readbuf[5] == 0x02)
						showProcessList("OK",Common.NULL,Common.OK);
					else{
						showProcessList("执行失败",Common.NULL,Common.OK);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}else if(stepType.substring(0, 3).equals("SHW")){ //SHW
				handlerSHW(stepType, true);
			}
		}
	}

	private void fun_T1N_PEPS1(Section section){
		if(!getpin()){
			showProcessList("未获取到PIN..",Common.NULL,Common.NG);
			return;
		}
		int num = Integer.valueOf(section.get("NUM"));
		int Pidfirst = Integer.valueOf(section.get("MODULE_ID"));
		int Pid = 0;
		String step_t = null;
//		String step_name = null;
		int error = 0;
		byte [] v_escl_status =new byte[10];	//ESCL状态
		byte [] v_immo_status =new byte[10];	//IMMO状态
		byte [] v_hcu_status = new byte[10];	//hcu状态
		byte [] v_trans_status = new byte[10];	//转发器状态
		String status;
		byte [] seed = new byte[8];
		byte [] key = new byte[8];
		byte [] cmd_link = {0x02,0x3E,(byte) 0x00};
		int bcm_time = 6;
		int key_retry = Integer.valueOf(section.get("KEY_RETRY"));
		int key_wait = Integer.valueOf(section.get("KEY_WAIT"));
		m_com.m_log.PrintAppend(0,"GetPin:" + Commonfunc.bytesToHexStringP(cartype.pin, 0, 4));
		for(int i = 1; i <= num; i ++)
		{
			Pid = Pidfirst + i;
			step_t = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			showTip(stepName + "...");
			if(step_t.length() < 3) continue;
			if(step_t.substring(0, 3).equals("CMD"))  //cmd
			{
				//获取cmd长度
				int cmdlen = Commonfunc.hexStringtoInt(step_t.substring(4, 6));
				byte [] cmd = new byte[cmdlen + 1];
				if(Commonfunc.CmdStringToBytes(step_t.substring(4), cmd, cmdlen + 1) > cmd.length) return;
				//---------------------发送前处理---------------------
				//复位重试次数
				if(i == 43 || i == 52)
					key_retry = Integer.valueOf(section.get("KEY_RETRY"));
				//设置CAN
				if(i == 1 || i == 9 || i == 34 || i == 43 || i == 64)//IMMO
				{
					if(!SetCanInitial("IMMO1",canid))return;
				}
				else if(i == 23 || i == 40) //切换至EMS
				{
					if(!SetCanInitial("HCU1",canid))return;
				}
				else if(i == 2 || i == 61 || i == 69)//切换至PEPS
				{
					if(i == 61) //判断执行ESCL
					{
						if(cartype.getMap("TCU")>0)
							break;
					}
					if(!SetCanInitial("PEPS1",canid))return;
				}
				//条件
				if(i == 5) //PEPS sa3
				{
					if((seed[0] | seed[1]) == 0) continue;
					Security.hefei_BCM_safekey(seed,key);
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				}
				else if(cmd[1] == 0x27 && cmd[2] == 0x04)//安全认证1
				{
					if((seed[0] | seed[1] | seed[2] | seed[3]) == 0) continue;
					Security.CX62_IMMO_Safekey(seed, key,0);
					System.arraycopy(key, 0, cmd, 3, 8);
				}
				else if(cmd[1] == 0x27 && cmd[2] == 0x06)//安全认证2
				{
					if((seed[0] | seed[1] | seed[2] | seed[3] | seed[4] | seed[5] | seed[6] | seed[7]) == 0) continue;
					int pin=(cartype.pin[0]&0xFF) * 0x1000000 + (cartype.pin[1]&0xFF) * 0x10000 +
							(cartype.pin[2]&0xFF) * 0x100 + (cartype.pin[3]&0xFF) * 0x01;
					Security.CX62_IMMO_Safekey(seed, key,pin);
					System.arraycopy(key, 0, cmd, 3, 8);
				}
				else if(i == 6) //config
				{
					System.arraycopy(cartype.byteConfig, 0, cmd, 4, (cmd[0]&0xFF) - 3);
				}
				else if(i == 14 || i == 27){ //写VIN
					System.arraycopy(cartype.vin, 0, cmd, 4, 17);
				}
				else if(i == 15)//IMMO写PIN
				{
					if((v_immo_status[1] & 0x04) == 0x04)	continue;
					System.arraycopy(cartype.pin, 0, cmd, 4, 4);
				}else if(i == 28){ //EMS写PIN
					System.arraycopy(cartype.pin, 0, cmd, 4, 4);
				}
				else if(i == 19 || i == 20 || i == 21 || i == 47 || i == 48 || i == 49)//第1把钥匙
				{
					//判断
					if(((v_trans_status[0] >> 5)& 0x01) == 1) //已关联
					{
						i += 3;continue;
					}
					else if(((v_trans_status[0] >> 3)&0x01) == 1)//旧钥匙未关联
					{
						cmd[4] = 0x01;
					}
				}
				else if(i == 43)//提示更换第二把钥匙
				{
//					for(int kk = bcm_time; kk >= 0; kk --){
//						showTip("更换钥匙2.."+kk+"s");
//						Commonfunc.sleep(1000);
//					}
					handlerSHW("SHW:NO<0>","请更换钥匙2......", true);
				}
				else if(i == 52) //提示更换第3把钥匙
				{
					if(true){//没有BM则不学习第三把钥匙
						i += 8;
						continue;
					}
					for(int kk = bcm_time; kk >= 0; kk --){
						showTip("更换钥匙3.."+kk+"s");
						Commonfunc.sleep(1000);
					}
				}
				else if(i == 8 || i == 20 || i == 48 || i == 57 || i == 68)
				{
					Sleep(3000);
				}
				//添加link
				if(i > 24 && i < 33)
				{
					error = m_com.CanSendOneOnly(canid[0],cmd_link,cmd_link.length);
//					bluetooth.CanSendAndRecvN2N(cmd_link, cmd_link.length, Readbuf, Readbuf.length, 1, Common.CMD_MAX_TIME*2);
					Sleep(100);
				}

				if(i == 19 || i == 33 || i == 37 || i == 47 || i == 56 || i == 67)
					error=m_com.CanOne2OneUDS(canid[0],canid[1],cmd,cmd.length,readbuf,5003,Common.CMD_MAX_TIME*2,2);
//					error = bluetooth.CanSendAndRecvN2N(cmd, cmd.length, Readbuf, Readbuf.length, 1,Common.CMD_MAX_TIME*2);
				else
					error=m_com.CanOne2OneUDS(canid[0],canid[1],cmd,cmd.length,readbuf,5003,Common.CMD_MAX_TIME*2,2);
//					error = bluetooth.CanSendAndRecvN2N(cmd, cmd.length, Readbuf, Readbuf.length, 1,Common.CMD_MAX_TIME*2);
				Sleep(Common.WAIT_TIME);
				//错误处理
				if(error == 5001){ //通讯超时
					showProcessList("通讯超时!",Common.NULL,Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
//				else
//					showProcessListHide(Commonfunc.bytesToHexString(Readbuf, 1,Readbuf[0] + 1),Common.OK);
				//特殊处理返回结果
				String t_step = String.valueOf(Pid); //显示测试结果
				if(i == 71)//key on,后等待10秒
				{
					if(((readbuf[4] >> 0) & 0x01) == 0x01)//ON
					{
						for(int k = 10; k > 0; k --)
						{
							showTip("key on  等待"+k+"秒");
							Sleep(1000);
						}
					}
					else
					{
						i --;
						Sleep(500);
					}
				}
				else if(i == 62) //key off
				{
					if(((readbuf[4] >> 0) & 0x01) == 0x00)//off
					{
					}
					else
					{
						i --;
						Sleep(500);
					}
				}
				else if(readbuf[1] == 0x67 && ((readbuf[2] == 0x3) || (readbuf[2] == 0x5) || (readbuf[2] == 0x7))  )
				{ //获取SEED
					System.arraycopy(readbuf, 3,seed,0,readbuf[0] - 2);
				}
				else if(i == 10) //读IMMO状态
				{
					System.arraycopy(readbuf, 4,v_immo_status,0,4);
					if((v_immo_status[1]) != 0){
						showProcessList("IMMO已学过",Common.NULL,Common.OK);
					}
					if(((v_immo_status[1] >> 1) & 0x01) == 0x01) //VIN已写
						status="VIN:1;";
					else
						status="VIN:0;";
					if(((v_immo_status[1] >> 2) & 0x01) == 0x01) //VIN已写
						status+="PIN:1;";
					else
						status+="PIN:0;";
					int nu = (v_immo_status[1] >> 3) & 0x07;
					status+="KEY:"+nu;
					if(((v_immo_status[1]&0x06) == 0x06) && nu == 2)
					{
						showProcessList(status,Common.NULL,Common.OK);
						//return;
					}
					else
						showProcessList(status,Common.NULL,Common.OK);
				}
				else if(i == 11 || i == 44 || i == 50 || i == 58)//读转发器状态
				{
					System.arraycopy(readbuf, 4,v_trans_status,0,4);
					String Result=Common.OK;
					if((v_trans_status[0] & 0x01) == 0x01) //防盗线圈故障
						status="Ring:1;";
					else{
						status="Ring:0;";
						Result = Common.NG;
					}
					if(((v_trans_status[0] >> 3) & 0x01) == 0x01) //new
						status+="New:0;";
					else
						status+="New:1;";
					if(((v_trans_status[0] >> 4) & 0x01) == 0x01) //SK
						status+="SK:1;";
					else
						status+="SK:0;";
					showProcessList(status,Common.NULL,Result);

				}
				else if(i == 8) //config
				{
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					int iRet = 2 - Commonfunc.bytesCompare(vin, cartype.byteConfig);
					if (iRet==1) {
						showProcessList(Commonfunc.bytesToHexStringP(vin, 0, (readbuf[0] & 0xFF) - 3),Common.NULL, Common.OK);
					}else if (iRet==0){
						showProcessList(Commonfunc.bytesToHexStringP(vin, 0, (readbuf[0] & 0xFF) - 3),Common.NULL, Common.NG);
					}
					if(iRet == 2) break;
				}
				else if(i == 16 || i == 29){ //读VIN,显示
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					showProcessList(new String(vin),new String(vin),Common.OK);
				}
				else if(i == 20 || i == 38 || i == 48 || i == 57 || i == 68){ //15检查钥匙学习结果,33检查EMS学习SK情况,45key2,63tcu,68 immo teach tcu,77immo teach escl
					if(readbuf[5] == 0x01 || readbuf[5] == 0x03)//继续
					{
						Sleep(500);
						i --;
					}else if(readbuf[5] == 0x02) {//OK
						showProcessList("ok",Common.NULL,Common.OK);
					}else if(readbuf[5] == 0x04){ //stop
						showProcessList("Routine stopped!",Common.NULL,Common.NG);
						break;
					}else {	//stop
						showProcessList("Routine failure and routine not run!",Common.NULL,Common.NG);
						i = 69;continue;
					}
				}else if(i == 22 || i == 50)
				{ //检查转发器状态
					System.arraycopy(readbuf, 4,v_trans_status,0,4);
					if((v_trans_status[0] & 0x20) == 0x20) //已经配对
						showProcessList("",Common.NULL,Common.OK);
					else{
						showProcessList(readbuf[5]+"",Common.NULL,Common.NG);
					}
				}else if(i == 24 || i == 41){ //读取HCU状态
					System.arraycopy(readbuf, 4,v_hcu_status,0,4);
					if(((v_hcu_status[1] >> 1) & 0x01) == 0x01) //VIN
						status="VIN:1;";
					else
						status="VIN:0;";
					if(((v_hcu_status[1] >> 2) & 0x01) == 0x01) //PIN
						status+="PIN:1;";
					else
						status+="PIN:0;";
					if(((v_hcu_status[1] >> 3) & 0x01) == 0x01) //SK
						status+="SK:1;";
					else
						status+="SK:0;";
					if(i == 24)
					{
						if(((v_hcu_status[1] >> 1) & 0x07) == 0x07){ //EMS已经学习过
							i = 41;
							showProcessList(status,Common.NULL,Common.OK);
							continue;
						}
						else
							showProcessList(status,Common.NULL,Common.NULL);
					}
					else if(i == 41)
					{
						if(((v_hcu_status[1] >> 1) & 0x07) == 0x07){ //EMS已经学习过
							showProcessList(status,Common.NULL,Common.OK);
						}
						else
							showProcessList(status,Common.NULL,Common.NG);
					}
				}
				else if(i == 60){ //检查钥匙数量
					System.arraycopy(readbuf, 4,v_immo_status,0,4);
					int keynum = (v_immo_status[1] >> 3) & 0x07; //关联的钥匙数量
					boolean v_isc =false;
					//if(Common.cartype.getMap("BM")>0)
					v_isc = false;
					byte isok = 1;
					if(v_isc)
					{
						if(keynum != 3)
							isok = 0;
					}
					else
					{
						if(keynum != 2)
							isok = 0;
					}
					if ((2-isok)==1){
						showProcessList(keynum+"把",Common.NULL,Common.OK);
					}else showProcessList(keynum+"把",Common.NULL,Common.NG);
				}else if(i == 63)//ESCL学习结果
				{
					System.arraycopy(readbuf, 4,v_escl_status,0,1);
					if(v_escl_status[0] != 0x00){ //不OK
						showProcessList("ESCL已经学习过!",Common.NULL,Common.OK);
						i += 6;
						continue;
					}else
						showProcessList("ESCL开始学习!",Common.NULL,Common.OK);
				}else if(i == 69){//ESCL学习结果
					System.arraycopy(readbuf, 4,v_escl_status,0,1);
					if(v_escl_status[0] != 0x01){ //不OK
						showProcessList("ESCL认证失败!",Common.NULL,Common.NG);
					}else
						showProcessList("ESCL OK!",Common.NULL,Common.OK);
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
			else if(step_t.substring(0, 3).equals("SHW")){ //SHW
				handlerSHW(step_t, true);
			}
		}
	}
	private void fun_T1P_PEPS2(Section section){
		if(!getpin()){
			showProcessList("未获取到PIN..",Common.NULL,Common.NG);
			return;
		}
		int num = Integer.valueOf(section.get("NUM"));
		int Pidfirst = Integer.valueOf(section.get("MODULE_ID"));
		int Pid = 0;
		String step_t = null;
//		String step_name = null;
		int error = 0;
		byte [] v_escl_status =new byte[10];	//ESCL状态
		byte [] v_immo_status =new byte[10];	//IMMO状态
		byte [] v_hcu_status = new byte[10];	//hcu状态
		byte [] v_trans_status = new byte[10];	//转发器状态
		String status;
		byte [] seed = new byte[8];
		byte [] key = new byte[8];
		byte [] cmd_link = {0x02,0x3E,(byte) 0x00};
		int bcm_time = 6;
		int key_retry = Integer.valueOf(section.get("KEY_RETRY"));
		int key_wait = Integer.valueOf(section.get("KEY_WAIT"));
		m_com.m_log.PrintAppend(0,"GetPin:" + Commonfunc.bytesToHexStringP(cartype.pin, 0, 4));
		for(int i = 1; i <= num; i ++)
		{
			Pid = Pidfirst + i;
			step_t = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			showTip(stepName + "...");
			if(step_t.length() < 3) continue;
			if(step_t.substring(0, 3).equals("CMD"))  //cmd
			{
				//获取cmd长度
				int cmdlen = Commonfunc.hexStringtoInt(step_t.substring(4, 6));
				byte [] cmd = new byte[cmdlen + 1];
				if(Commonfunc.CmdStringToBytes(step_t.substring(4), cmd, cmdlen + 1) > cmd.length) return;
				//---------------------发送前处理---------------------
				//复位重试次数
				if(i == 43 || i == 52)
					key_retry = Integer.valueOf(section.get("KEY_RETRY"));
				//设置CAN
				if(i == 1 || i == 9 || i == 34 || i == 43 || i == 64)//IMMO
				{
					if(!SetCanInitial("IMMO1",canid))return;
				}
				else if(i == 23 || i == 40) //切换至EMS
				{
					if(!SetCanInitial("HCU1",canid))return;
				}
				else if(i == 2 || i == 61 || i == 69)//切换至PEPS
				{
					if(i == 61) //判断执行ESCL
					{
						if(cartype.getMap("TCU")>0)
							break;
					}
					if(!SetCanInitial("PEPS1",canid))return;
				}
				if(cmd[1] == 0x27 && cmd[2] == 0x04)//安全认证1
				{
					if((seed[0] | seed[1] | seed[2] | seed[3]) == 0) continue;
					Security.CX62_IMMO_Safekey(seed, key,0);
					System.arraycopy(key, 0, cmd, 3, 8);
				}
				else if(cmd[1] == 0x27 && cmd[2] == 0x06)//安全认证2
				{
					if((seed[0] | seed[1] | seed[2] | seed[3] | seed[4] | seed[5] | seed[6] | seed[7]) == 0) continue;
					int pin=(cartype.pin[0]&0xFF) * 0x1000000 + (cartype.pin[1]&0xFF) * 0x10000 +
							(cartype.pin[2]&0xFF) * 0x100 + (cartype.pin[3]&0xFF) * 0x01;
					Security.CX62_IMMO_Safekey(seed, key,pin);
					System.arraycopy(key, 0, cmd, 3, 8);
				}
				else if(i == 6) //config
				{
					System.arraycopy(cartype.byteConfig, 0, cmd, 4, (cmd[0]&0xFF) - 3);
				}
				else if(i == 14 || i == 27){ //写VIN
					System.arraycopy(cartype.vin, 0, cmd, 4, 17);
				}
				else if(i == 15)//IMMO写PIN
				{
					if((v_immo_status[1] & 0x04) == 0x04)	continue;
					System.arraycopy(cartype.pin, 0, cmd, 4, 4);
				}else if(i == 28){ //EMS写PIN
					System.arraycopy(cartype.pin, 0, cmd, 4, 4);
				}
				else if(i == 19 || i == 20 || i == 21 || i == 47 || i == 48 || i == 49)//第1把钥匙
				{
					//判断
					if(((v_trans_status[0] >> 5)& 0x01) == 1) //已关联
					{
						i += 3;continue;
					}
					else if(((v_trans_status[0] >> 3)&0x01) == 1)//旧钥匙未关联
					{
						cmd[4] = 0x01;
					}
				}
				else if(i == 43)//提示更换第二把钥匙
				{
//					for(int kk = bcm_time; kk >= 0; kk --){
//						showTip("更换钥匙2.."+kk+"s");
//						Commonfunc.sleep(1000);
//					}
					handlerSHW("SHW:NO<0>","请更换钥匙2......", true);
				}
				else if(i == 52) //提示更换第3把钥匙
				{
					if(true){//没有BM则不学习第三把钥匙
						i += 8;
						continue;
					}
					for(int kk = bcm_time; kk >= 0; kk --){
						showTip("更换钥匙3.."+kk+"s");
						Commonfunc.sleep(1000);
					}
				}
				else if(i == 8 || i == 20 || i == 48 || i == 57 || i == 68)
				{
					Sleep(3000);
				}
				//添加link
				if(i > 24 && i < 33)
				{
					error = m_com.CanSendOneOnly(canid[0],cmd_link,cmd_link.length);
//					bluetooth.CanSendAndRecvN2N(cmd_link, cmd_link.length, Readbuf, Readbuf.length, 1, Common.CMD_MAX_TIME*2);
					Sleep(100);
				}

				if(i == 19 || i == 33 || i == 37 || i == 47 || i == 56 || i == 67)
					error=m_com.CanOne2OneUDS(canid[0],canid[1],cmd,cmd.length,readbuf,5003,Common.CMD_MAX_TIME*2,2);
//					error = bluetooth.CanSendAndRecvN2N(cmd, cmd.length, Readbuf, Readbuf.length, 1,Common.CMD_MAX_TIME*2);
				else
					error=m_com.CanOne2OneUDS(canid[0],canid[1],cmd,cmd.length,readbuf,5003,Common.CMD_MAX_TIME*2,2);
//					error = bluetooth.CanSendAndRecvN2N(cmd, cmd.length, Readbuf, Readbuf.length, 1,Common.CMD_MAX_TIME*2);
				Sleep(Common.WAIT_TIME);
				Sleep(Common.WAIT_TIME);
				//错误处理
				if(error == 5001){ //通讯超时
					showProcessList("通讯超时!",Common.NULL,Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
//				else
//					showProcessListHide(Commonfunc.bytesToHexString(Readbuf, 1,Readbuf[0] + 1),Common.OK);
				//特殊处理返回结果
				String t_step = String.valueOf(Pid); //显示测试结果
				if(i == 71)//key on,后等待10秒
				{
					if(((readbuf[4] >> 0) & 0x01) == 0x01)//ON
					{
						for(int k = 10; k > 0; k --)
						{
							showTip("key on  等待"+k+"秒");
							Sleep(1000);
						}
					}
					else
					{
						i --;
						Sleep(500);
					}
				}
				else if(i == 62) //key off
				{
					if(((readbuf[4] >> 0) & 0x01) == 0x00)//off
					{
					}
					else
					{
						i --;
						Sleep(500);
					}
				}
				else if(readbuf[1] == 0x67 && ((readbuf[2] == 0x3) || (readbuf[2] == 0x5) || (readbuf[2] == 0x7))  )
				{ //获取SEED
					System.arraycopy(readbuf, 3,seed,0,readbuf[0] - 2);
				}
				else if(i == 10) //读IMMO状态
				{
					System.arraycopy(readbuf, 4,v_immo_status,0,4);
					if((v_immo_status[1]) != 0){
						showProcessList("IMMO已学过",Common.NULL,Common.OK);
					}
					if(((v_immo_status[1] >> 1) & 0x01) == 0x01) //VIN已写
						status="VIN:1;";
					else
						status="VIN:0;";
					if(((v_immo_status[1] >> 2) & 0x01) == 0x01) //VIN已写
						status+="PIN:1;";
					else
						status+="PIN:0;";
					int nu = (v_immo_status[1] >> 3) & 0x07;
					status+="KEY:"+nu;
					if(((v_immo_status[1]&0x06) == 0x06) && nu == 2)
					{
						showProcessList(status,Common.NULL,Common.OK);
						//return;
					}
					else
						showProcessList(status,Common.NULL,Common.OK);
				}
				else if(i == 11 || i == 44 || i == 50 || i == 58)//读转发器状态
				{
					System.arraycopy(readbuf, 4,v_trans_status,0,4);
					String Result=Common.OK;
					if((v_trans_status[0] & 0x01) == 0x01) //防盗线圈故障
						status="Ring:1;";
					else{
						status="Ring:0;";
						Result = Common.NG;
					}
					if(((v_trans_status[0] >> 3) & 0x01) == 0x01) //new
						status+="New:0;";
					else
						status+="New:1;";
					if(((v_trans_status[0] >> 4) & 0x01) == 0x01) //SK
						status+="SK:1;";
					else
						status+="SK:0;";
					showProcessList(status,Common.NULL,Result);

				}
				else if(i == 8) //config
				{
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					int iRet = 2 - Commonfunc.bytesCompare(vin, cartype.byteConfig);
					if (iRet==1) {
						showProcessList(Commonfunc.bytesToHexStringP(vin, 0, (readbuf[0] & 0xFF) - 3),Common.NULL, Common.OK);
					}else if (iRet==0){
						showProcessList(Commonfunc.bytesToHexStringP(vin, 0, (readbuf[0] & 0xFF) - 3),Common.NULL, Common.NG);
					}
					if(iRet == 2) break;
				}
				else if(i == 16 || i == 29){ //读VIN,显示
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					showProcessList(new String(vin),new String(vin),Common.OK);
				}
				else if(i == 20 || i == 38 || i == 48 || i == 57 || i == 68){ //15检查钥匙学习结果,33检查EMS学习SK情况,45key2,63tcu,68 immo teach tcu,77immo teach escl
					if(readbuf[5] == 0x01 || readbuf[5] == 0x03)//继续
					{
						Sleep(500);
						i --;
					}else if(readbuf[5] == 0x02) {//OK
						showProcessList("ok",Common.NULL,Common.OK);
					}else if(readbuf[5] == 0x04){ //stop
						showProcessList("Routine stopped!",Common.NULL,Common.NG);
						break;
					}else {	//stop
						showProcessList("Routine failure and routine not run!",Common.NULL,Common.NG);
						i = 69;continue;
					}
				}else if(i == 22 || i == 50)
				{ //检查转发器状态
					System.arraycopy(readbuf, 4,v_trans_status,0,4);
					if((v_trans_status[0] & 0x20) == 0x20) //已经配对
						showProcessList("",Common.NULL,Common.OK);
					else{
						showProcessList(readbuf[5]+"",Common.NULL,Common.NG);
					}
				}else if(i == 24 || i == 41){ //读取HCU状态
					System.arraycopy(readbuf, 4,v_hcu_status,0,4);
					if(((v_hcu_status[1] >> 1) & 0x01) == 0x01) //VIN
						status="VIN:1;";
					else
						status="VIN:0;";
					if(((v_hcu_status[1] >> 2) & 0x01) == 0x01) //PIN
						status+="PIN:1;";
					else
						status+="PIN:0;";
					if(((v_hcu_status[1] >> 3) & 0x01) == 0x01) //SK
						status+="SK:1;";
					else
						status+="SK:0;";
					if(i == 24)
					{
						if(((v_hcu_status[1] >> 1) & 0x07) == 0x07){ //EMS已经学习过
							i = 41;
							showProcessList(status,Common.NULL,Common.OK);
							continue;
						}
						else
							showProcessList(status,Common.NULL,Common.NULL);
					}
					else if(i == 41)
					{
						if(((v_hcu_status[1] >> 1) & 0x07) == 0x07){ //EMS已经学习过
							showProcessList(status,Common.NULL,Common.OK);
						}
						else
							showProcessList(status,Common.NULL,Common.NG);
					}
				}
				else if(i == 60){ //检查钥匙数量
					System.arraycopy(readbuf, 4,v_immo_status,0,4);
					int keynum = (v_immo_status[1] >> 3) & 0x07; //关联的钥匙数量
					boolean v_isc =false;
					//if(Common.cartype.getMap("BM")>0)
					v_isc = false;
					byte isok = 1;
					if(v_isc)
					{
						if(keynum != 3)
							isok = 0;
					}
					else
					{
						if(keynum != 2)
							isok = 0;
					}
					if ((2-isok)==1){
						showProcessList(keynum+"把",Common.NULL,Common.OK);
					}else showProcessList(keynum+"把",Common.NULL,Common.NG);
				}else if(i == 63)//ESCL学习结果
				{
					System.arraycopy(readbuf, 4,v_escl_status,0,1);
					if(v_escl_status[0] != 0x00){ //不OK
						showProcessList("ESCL已经学习过!",Common.NULL,Common.OK);
						i += 6;
						continue;
					}else
						showProcessList("ESCL开始学习!",Common.NULL,Common.OK);
				}else if(i == 69){//ESCL学习结果
					System.arraycopy(readbuf, 4,v_escl_status,0,1);
					if(v_escl_status[0] != 0x01){ //不OK
						showProcessList("ESCL认证失败!",Common.NULL,Common.NG);
					}else
						showProcessList("ESCL OK!",Common.NULL,Common.OK);
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
			else if(step_t.substring(0, 3).equals("SHW")){ //SHW
				handlerSHW(step_t, true);
			}
		}
	}


	private void fun_CX62B_PEPS1(Section section){
		if(!getpin()){
			showProcessList("未获取到PIN码",Common.NULL,Common.NG);
			return;
		}
		else
			ecuModule.addcontext("PIN:" + Commonfunc.bytesToHexStringP(cartype.pin,0,4));
		byte [] v_escl_status =new byte[10];	//ESCL状态
		byte [] v_tcu_status = new byte[10];	//TCU状态
		byte [] v_immo_status =new byte[10];	//IMMO状态
		byte [] v_ems_status = new byte[10];	//EMS状态
		byte [] v_trans_status = new byte[10];	//转发器状态
		int key_retry = Integer.valueOf(section.get("KEY_RETRY"));
		int key_wait = Integer.valueOf(section.get("KEY_WAIT"));
		int bcm_time = 6;
		boolean veleo = false;
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				//---------------------发送前处理---------------------
				if(i == 43 || i == 52)
					key_retry = Integer.valueOf(section.get("KEY_RETRY"));

				if(i == 1 || i == 9 || i == 34 || i == 43 || i == 64)//IMMO
				{		//切换至IMMO
					if(!SetCanInitial("IMMO1",canid)) return;
				}else if(i == 23 || i == 40) //切换至EMS
				{	//切换至EMS
					if(!SetCanInitial("EMS1",canid)) return;
				}
				else if(i == 2 || i == 61 || i == 69)//切换至PEPS
				{
					if(i == 61) //判断执行ESCL
					{
						if(cartype.getMap("TCU")>0)
							break;
					}
					if(!SetCanInitial("PEPS1",canid)) return;
				}
				if(i == 5){ //安全认证1
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}else  if(i == 13 || i == 26 )//安全认证1
				{
					if((seed[0] | seed[1] | seed[2] | seed[3]) == 0) continue;
					Security.CX62_IMMO_Safekey(seed, key,0);
					System.arraycopy(key, 0, cmd, 3, 8);
				}
				else if(i == 18 || i == 32 || i == 36 || i == 46 || i == 55 || i == 66){ //安全认证2
					if((seed[0] | seed[1] | seed[2] | seed[3]) == 0) continue;
					int pin=(cartype.pin[0]&0xFF) * 0x1000000 + (cartype.pin[1]&0xFF) * 0x10000 +
							(cartype.pin[2]&0xFF) * 0x100 + (cartype.pin[3]&0xFF) * 0x01;
					Security.CX62_IMMO_Safekey(seed, key,pin);
					System.arraycopy(key, 0, cmd, 3, 8);
				}else if(i == 6) //config
				{
					System.arraycopy(cartype.byteConfig, 0, cmd, 4, (cmd[0]&0xFF) - 3);
				}
				else if(i == 14 || i == 27){ //写VIN
					System.arraycopy(cartype.vin, 0, cmd, 4, 17);
				}else if(i == 15){ //IMMO写PIN
					if((v_immo_status[1] & 0x04) == 0x04){ //VIN、PIN已写
						continue;
					}
					System.arraycopy(cartype.pin, 0, cmd, 4, 4);
				}else if(i == 28){ //EMS写PIN
					if(((v_ems_status[1] >> 2) & 0x01) == 0x01) continue;
					System.arraycopy(cartype.pin, 0, cmd, 4, 4);
				}
				else if(i == 19 || i == 20 || i == 21 || i == 47 || i == 48 || i == 49)//第1把钥匙
				{
					//判断
					if(((v_trans_status[0] >> 5)& 0x01) == 1) //已关联
					{
						i += 3;continue;
					}
					else if(((v_trans_status[0] >> 3)&0x01) == 1)//旧钥匙未关联
					{
						cmd[4] = 0x01;
					}
				}
				else if(i == 43)//提示更换第二把钥匙
				{
					//for(int kk = bcm_time; kk >= 0; kk --){
					//	showTip("更换钥匙2.."+kk+"s");
					//	Commonfunc.sleep(1000);
					//}
					handlerSHW("SHW:NO<0>","请更换钥匙2......", true);
				}
				else if(i == 52) //提示更换第3把钥匙
				{
					if(true){//没有BM则不学习第三把钥匙
						i += 8;
						continue;
					}
					bcm_time = 6;
					/*for(int kk = bcm_time; kk >= 0; kk --){
						showTip("更换钥匙3.."+kk+"s");
						Commonfunc.sleep(1000);
						if((kk % 2) == 0){
//							bluetooth.canSendAndRecvN2N(keep, readbuf, Common.CMD_MAX_TIME);
							m_com.CanSendOneOnly(canid[0],keep,keep.length);
						}
					}*/
					handlerSHW("SHW:NO<0>","请更换钥匙3......", true);
				}
				else if(i == 8 || i == 20 || i == 48 || i == 57 || i == 68)
				{
					Sleep(3000);
				}

//				error = bluetooth.canSendAndRecvN2N(cmd, readbuf, Common.CMD_MAX_TIME);
				if(i == 19 || i == 33 || i == 37 || i == 47 || i == 56 || i == 67)
					error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME * 2, 2);
				else
					error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				if(error == 5001){
					if(i == 1  && !veleo){
						veleo = true;
						i--;
					}
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{

					if(i == 1  && !veleo){
						veleo = true;
						i--;
					}
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if(i == 1  && !veleo){
						veleo = true;
						i--;
					}
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i == 71)//key on,后等待10秒
				{
					if(((readbuf[4] >> 0) & 0x01) == 0x01)//ON
					{
						for(int k = 10; k > 0; k --)
						{
							showTip("key on  等待"+k+"秒");
							Sleep(1000);
						}
					}
					else
					{
						i --;
						Sleep(500);
					}
				}
				else if(i == 62) //key off
				{
					if(((readbuf[4] >> 0) & 0x01) == 0x00)//off
					{
					}
					else
					{
						i --;
						Sleep(500);
					}
				}else if(i == 10){	//读IMMO状态
					System.arraycopy(readbuf, 4,v_immo_status,0,4);
					if((v_immo_status[1]) != 0){
						showProcessList("IMMO已学过",Common.NULL,Common.OK);
					}
					else
					{
						String status = "";
						if(((v_immo_status[1] >> 1) & 0x01) == 0x01) //VIN已写
							status="VIN:1;";
						else
							status="VIN:0;";
						if(((v_immo_status[1] >> 2) & 0x01) == 0x01) //VIN已写
							status+="PIN:1;";
						else
							status+="PIN:0;";
						int nu = (v_immo_status[1] >> 3) & 0x07;
						status+="KEY:"+nu;
						showProcessList(status,"",Common.OK);
					}
				}else if(i == 11 || i == 44 || i == 50 || i == 58)//读转发器状态
				{	System.arraycopy(readbuf, 4,v_trans_status,0,4);
					int Result = 1;
					String status;
					if((v_trans_status[0] & 0x01) == 0x01) //防盗线圈故障
						status="Ring:1;";
					else{
						status="Ring:0;";
						//Result = 2;
					}
					if(((v_trans_status[0] >> 3) & 0x01) == 0x01) //new
						status+="New:0;";
					else
						status+="New:1;";
					if(((v_trans_status[0] >> 4) & 0x01) == 0x01) //SK
						status+="SK:1;";
					else
						status+="SK:0;";
					showProcessList(status,Common.NULL,Result == 2 ? Common.NG : Common.OK);
				}
				else if(i == 8) //config
				{
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					int iRet = 2 - Commonfunc.bytesCompare(vin, cartype.byteConfig);
					showProcessList(Commonfunc.bytesToHexStringP(vin, 0, (readbuf[0]&0xFF) - 3),"",iRet == 2 ? Common.NG : Common.OK);
					if(iRet == 2) break;
				}else if(i == 4 || i == 12 || i == 17 || i == 25 || i == 31 || i == 35 || i == 45 || i == 54  || i == 65){ //获取SEED
					System.arraycopy(readbuf, 3, seed, 0, 8);
				}else if(i == 16 || i == 29){ //读VIN,显示
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					showProcessList(new String(vin),new String(vin),Common.OK);
				}else if(i == 20 || i == 38 || i == 48 || i == 57 || i == 68){ //15检查钥匙学习结果,33检查EMS学习SK情况,45key2,63tcu,68 immo teach tcu,77immo teach escl
					if(readbuf[5] == 0x01 || readbuf[5] == 0x03){ //继续
						Commonfunc.sleep(500);
						i --;
					}else if(readbuf[5] == 0x02) {//OK
						showProcessList("OK",Common.NULL,Common.OK);
					}else if(readbuf[5] == 0x04){ //stop
						showProcessList("Routine stopped!",Common.NULL,Common.NG);
						break;
					}else{	//stop
						showProcessList("Routine failure and routine not run!",Common.NULL,Common.NG);
						i = 69;continue;
					}
				}else if(i == 22 || i == 50){ //检查转发器状态
					System.arraycopy(readbuf, 4,v_trans_status,0,4);
					if((v_trans_status[0] & 0x20) == 0x20) //已经配对
						showProcessList("",Common.NULL,Common.OK);
					else{
						showProcessList(readbuf[5]+"",Common.NULL,Common.NG);
					}
				}else  if(i == 24 || i == 41){ //读取EMS状态
					System.arraycopy(readbuf, 4,v_ems_status,0,4);
					String status;
					if(((v_ems_status[1] >> 1) & 0x01) == 0x01) //VIN
						status="VIN:1;";
					else
						status="VIN:0;";
					if(((v_ems_status[1] >> 2) & 0x01) == 0x01) //PIN
						status+="PIN:1;";
					else
						status+="PIN:0;";
					if(((v_ems_status[1] >> 3) & 0x01) == 0x01) //SK
						status+="SK:1;";
					else
						status+="SK:0;";
					showProcessList(status,Common.NULL,Common.OK);
					if(i == 24){
						if(((v_ems_status[1] >> 1) & 0x07) == 0x07){ //EMS已经学习过
							i = 41;
							continue;
						}
						else
							showProcessList(status,Common.NULL,Common.NULL);
					}
				}else if(i == 41){ //EMS状态,SK学习结果
					System.arraycopy(readbuf, 4,v_ems_status,0,4);
					if(((v_ems_status[1] >> 1) & 0x07) == 0x07) //EMS已经学习过
						showProcessList("VIN/PIN/SK",Common.NULL,Common.OK);
					else{
						showProcessList("SK",Common.NULL,Common.NG);
					}
				}else if(i == 60){ //检查钥匙数量
					System.arraycopy(readbuf, 4,v_immo_status,0,4);
					key_num = (v_immo_status[1] >> 3) & 0x07; //关联的钥匙数量
					boolean v_isc =false;
					if(key_num == 2){ //OK
						showProcessList("2把",Common.NULL,Common.OK);
					}else if(key_num == 3 && v_isc){ //OK
						showProcessList("3把",Common.NULL,Common.OK);
					}else{
						showProcessList(key_num+"把",Common.NULL,Common.NG);
						break;
					}
				}else if(i == 63){ //ESCL学习结果
					System.arraycopy(readbuf, 4,v_escl_status,0,1);
					if(v_escl_status[0] != 0x00){ //不OK
						showProcessList("ESCL 已经学习过!",Common.NULL,Common.OK);
						i = 88;
						continue;
					}else
						showProcessList("TSCL 开始学习!",Common.NULL,Common.OK);
				}else if(i == 69){//ESCL学习结果
					System.arraycopy(readbuf, 4,v_escl_status,0,1);
					if(v_escl_status[0] != 0x01){ //不OK
						showProcessList("ESCL authentication failure",Common.NULL,Common.NG);
					}else
						showProcessList("TSCL OK!",Common.NULL,Common.OK);
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}else if(stepType.substring(0, 3).equals("SHW")){ //SHW
				//handlerSHW(stepType, true);
			}
		}
	}
	private void fun_KX65EV_PEPS1(Section section){
		if(!getpin()){
			showProcessList("未获取到PIN码",Common.NULL,Common.NG);
			return;
		}
		byte [] v_immo_status =new byte[10];	//IMMO状态
		byte [] v_vcu_status = new byte[10];	//EMS状态
		byte [] v_trans_status = new byte[10];	//转发器状态

		boolean veleo = false;
		if(!SetCanInitial("IMMO1",canid)) return;
		int Pid = Integer.valueOf(section.get("MODULE_ID"));
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepId = Pid + i;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				//---------------------发送前处理---------------------
				if(i == 1 || i == 26 || i == 48) //切换至IMMO
				{
					if(!SetCanInitial("IMMO1",canid)) return;
//					}
				}else if(i == 15){		//切换至VCU
					if(!SetCanInitial("VCU1",canid)) return;
					//if((v_immo_status[1]&0x04) == 0x04) //IMMO已经学习
					//{
					//	i += 12;continue;
					//}
				}else if( i == 46 || i == 54){	//切换至PEPS
					if(!SetCanInitial("PEPS1",canid)) return;
				}else if(cmd[1] == 0x27 && (cmd[2] == 0x04 || cmd[2] == 0x06))//安全认证
				{
					if(seed[0] == 0) continue;
					int pin = 0;
					if(cmd[2] == 0x06)
						pin=(cartype.pin[0]&0xFF) * 0x1000000 + (cartype.pin[1]&0xFF) * 0x10000 +
								(cartype.pin[2]&0xFF) * 0x100 + (cartype.pin[3]&0xFF) * 0x01;
					Security.CX62_IMMO_Safekey(seed, key,pin);
					System.arraycopy(key, 0, cmd, 3, 8);
				}
				else if(cmd[1] == 0x2E && (cmd[2]&0xFF) == 0xF1 && (cmd[3]&0xFF) == 0x90)
				{
					System.arraycopy(cartype.vin, 0, cmd, 4, cmd[0] - 3);
				}
				else if(i == 8){ //IMMO写PIN
					if((v_immo_status[1] & 0x04) == 0x04){ //VIN、PIN已写
						continue;
					}
					System.arraycopy(cartype.pin, 0, cmd, 4, 4);
				}else if(i == 20){ //VCU写PIN
					if(((v_vcu_status[1] >> 2) & 0x01) == 0x01) continue;
					System.arraycopy(cartype.pin, 0, cmd, 4, 4);
				}else if(i == 28){ //提示更换第二把钥匙
					handlerSHW("SHW:TEXT<5>", "更换钥匙2..",true);
				}else if(i == 37){ //提示更换第3把钥匙
					if((cartype.byteConfig[4]&0x40)==0 || key_num == 3){//没有BM则不学习第三把钥匙
						i = 45 ;
						continue;
					}
					handlerSHW("SHW:TEXT<3>","更换钥匙3...", true);
				}else if(i == 12 || i == 32 || i == 41){
					if(cmd[1] == 0x31)
					{
						if(((v_trans_status[0] >> 5) & 0x01) == 0x01) //钥匙已关联
						{
							i += 1;continue;
						}
					}
					Commonfunc.sleep(1500);
				}
				if(i == 46)
				{
					handlerSHW("SHW:OFF<5>", false);
				}
				else if(i == 55)
				{
					handlerSHW("SHW:ON<5>", false);
				}
				else if(i == 28) //更换钥匙2
				{
					handlerSHW("SHW:NO<3>","更换钥匙2...", true);
				}
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);

				if(error == 5001){
					if(i == 1  && !veleo){
						veleo = true;
						i--;
					}
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}
				else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					if(i == 1  && !veleo){
						veleo = true;
						i--;
					}
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if(i == 1  && !veleo){
						veleo = true;
						i--;
					}
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}

				if(readbuf[1] == 0x62 && readbuf[2] == 0x01 && readbuf[3] == 0x08){ //读IMMO状态
					System.arraycopy(readbuf, 4,v_immo_status,0,readbuf[0] - 3);
					if((v_immo_status[1]) != 0){
						showProcessList("IMMO已学过",Common.NULL,Common.OK);
						//break;
					}
				}else if(readbuf[1] == 0x62 && readbuf[2] == 0x66 && readbuf[3] == 0x01){ //读转发器状态
					System.arraycopy(readbuf, 4,v_trans_status,0,readbuf[0] - 3);
					int Result = 1;
					String status;
					if((v_trans_status[0] & 0x01) == 0x01) //防盗线圈故障
						status="有钥匙";
					else{
						status="无钥匙";
						Result = 2;
					}
					if(((v_trans_status[0] >> 3) & 0x01) == 0x01) //new
						status+="CID:0;";
					else
						status+="CID:1;";
					if(((v_trans_status[0] >> 4) & 0x01) == 0x01) //SK
						status+="SK:1;";
					else
						status+="SK:0;";
					if(i == 14 || i == 34 || i == 43) //学习完成后检查
					{
						if(((v_trans_status[0] >> 5) & 0x01) == 0x01) //SK
							showProcessList("钥匙已关联",Common.NULL,Common.OK);
						else
							showProcessList("钥匙未关联",Common.NULL,Common.NG);
					}
					else
						showProcessList(status,Common.NULL,Result == 2 ? Common.NG : Common.OK);
				}else if(readbuf[1] == 0x62 && readbuf[2] == 0x6A && readbuf[3] == 0x09) //ESCL状态
				{
					if(i == 47)
					{
						if(readbuf[4] == 0x01)
						{
							showProcessList("ESCL已学习",Common.NULL,Common.OK);
							i += 6;continue;
						}
						else if(readbuf[4] > 0x01)
						{
							showProcessList("ESCL状态不允允许操作:" + readbuf[4],Common.NULL,Common.NG);
						}
					}
					else
					{
						if(readbuf[4] == 0x01)
						{
							showProcessList("ESCL学习成功",Common.NULL,Common.OK);
						}
						else
						{
							showProcessList("ESCL学习失败:" + readbuf[4],Common.NULL,Common.NG);
						}
					}

				}
				else if(readbuf[1] == 0x67 && (readbuf[2] == 0x03 || readbuf[2] == 0x05)){ //获取SEED
					System.arraycopy(readbuf, 3, seed, 0, 8);
				}else if(readbuf[1] == 0x62 && readbuf[2] == 0xF1 && readbuf[3] == 0x90){ //读VIN,显示
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					showProcessList(new String(vin),new String(vin),Common.OK);
				}else if(readbuf[1] == 0x71 && readbuf[2] == 0x01){ //学习钥匙
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1500);
				}else if(readbuf[1] == 0x71 && readbuf[2] == 0x03){ //15检查钥匙学习结果,33检查EMS学习SK情况,45key2,63tcu,68 immo teach tcu,77immo teach escl
					if(readbuf[5] == 0x01 || readbuf[5] == 0x03){ //继续
						if(i == 63) continue;
						Commonfunc.sleep(500);
						i --;
					}else if(readbuf[5] == 0x02) {//OK
						showProcessList("OK",Common.NULL,Common.OK);
					}else if(readbuf[5] == 0x04){ //stop
						showProcessList("Routine stopped!",Common.NULL,Common.NG);
						break;
					}else{	//stop
						showProcessList("Routine failure and routine not run!",Common.NULL,Common.NG);
						break;
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}else if(stepType.substring(0, 3).equals("SHW")){ //SHW
				handlerSHW(stepType, true);
			}
		}
	}

	private void fun_KX63A_PEPS1(Section section){
		if(!getpin()){
			showProcessList("未获取到PIN码",Common.NULL,Common.NG);
			return;
		}
		byte [] v_escl_status =new byte[10];	//ESCL状态
		byte [] v_tcu_status = new byte[10];	//TCU状态
		byte [] v_immo_status =new byte[10];	//IMMO状态
		byte [] v_ems_status = new byte[10];	//EMS状态
		byte [] v_trans_status = new byte[10];	//转发器状态
		int bcm_time = 6;
		boolean veleo = false;
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			if(i==79){
				int escl=(cartype.byteConfig[2]>>5)&0x07;
				if( escl!=0x00 && escl!=0x01)//只有变速箱类型为5MT和6MT时才做ESCL
					break;
			}
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				//---------------------发送前处理---------------------
				if(i == 1){
					if (cartype.getMap("BM")>0 || veleo){
						if(!SetCanInitial("PEPS1",canid)) return;
					}else{
						if(!SetCanInitial("BCM1",canid)) return;
					}
				}else if(i == 9 || i == 36 || i == 44 || i == 71 || i == 79 || i == 82 || i == 89){		//切换至IMMO
					if(!SetCanInitial("IMMO1",canid)) return;
				}else if(i == 25 || i == 42){	//切换至EMS
					if(!SetCanInitial("EMS1",canid)) return;
				}else if(i == 68 || i == 77){ //切换至TCU
					if(!SetCanInitial("TCU1",canid))return;
				}else if(i == 2 || i == 80 || i == 88 || i == 91){ //切换至PEPS
					if(!SetCanInitial("PEPS1",canid))return;
				}else if(i == 5 || i == 13 || i == 28 || i == 93){ //安全认证1
					if(seed[0] == 0) continue;
					Security.CX62_IMMO_Safekey(seed, key,0);
					System.arraycopy(key, 0, cmd, 3, 8);
				}else if (i == 6){
					System.arraycopy(cartype.byteConfig, 0, cmd, 4, cartype.byteConfig.length);
				}else if(i == 20 || i == 34 || i == 38 || i == 50 || i == 61 || i == 73 || i == 84){ //安全认证2
					if(seed[0] == 0) continue;
					int pin=(cartype.pin[0]&0xFF) * 0x1000000 + (cartype.pin[1]&0xFF) * 0x10000 +
							(cartype.pin[2]&0xFF) * 0x100 + (cartype.pin[3]&0xFF) * 0x01;
					Security.CX62_IMMO_Safekey(seed, key,pin);
					System.arraycopy(key, 0, cmd, 3, 8);
				}else if(i == 14 || i == 29){ //写VIN
					System.arraycopy(cartype.vin, 0, cmd, 4, 17);
				}else if(i == 16){ //IMMO写PIN
					if((v_immo_status[1] & 0x04) == 0x04){ //VIN、PIN已写
						continue;
					}
					System.arraycopy(cartype.pin, 0, cmd, 4, 4);
				}else if(i == 31){ //EMS写PIN
					if(((v_ems_status[1] >> 2) & 0x01) == 0x01) continue;
					System.arraycopy(cartype.pin, 0, cmd, 4, 4);
				}else if(i == 47){ //提示更换第二把钥匙
					for(int kk = bcm_time; kk >= 0; kk --){
						showTip("更换钥匙2.."+kk+"s");
						Commonfunc.sleep(1000);
					}
				}else if (i == 48 || i == 59){
					if((v_trans_status[0] & 0x01) != 0x01){ //防盗线圈故障
						break;
					}
				}else if(i == 58){ //提示更换第3把钥匙
					if((cartype.byteConfig[4]&0x40)==0 || key_num == 3){//没有BM则不学习第三把钥匙
						i = 66 ;
						continue;
					}
					bcm_time = 6;
					for(int kk = bcm_time; kk >= 0; kk --){
						showTip("更换钥匙3.."+kk+"s");
						Commonfunc.sleep(1000);
						if((kk % 2) == 0){
//							bluetooth.canSendAndRecvN2N(keep, readbuf, Common.CMD_MAX_TIME);
							m_com.CanSendOneOnly(canid[0],keep,keep.length);
						}
					}
				}else if(i == 24 || i == 54 || i == 64){
					Commonfunc.sleep(1500);
				}

//				error = bluetooth.canSendAndRecvN2N(cmd, readbuf, Common.CMD_MAX_TIME);
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);

				if(error == 5001){
					if(i == 1  && !veleo){
						veleo = true;
						i--;
					}
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}
				else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					if(i == 1  && !veleo){
						veleo = true;
						i--;
					}
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if(i == 1  && !veleo){
						veleo = true;
						i--;
					}
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}

				if(i == 1){//KEY ON,后等待10秒
					if(((readbuf[4] >> 3) & 0x01) == 0x01){ //ON		//
						for(int k = 2; k >= 0; k --){
							showTip("KEY ON  等待" + k + "s");
							Commonfunc.sleep(1000);
						}
					}else{
						showTip("请打开钥匙...");
						Commonfunc.sleep(1000);
						i --;
					}
				}else if(i == 7){
					Commonfunc.sleep(1000);
				}else if(i == 8){ //读VIN,显示
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.byteConfig)){
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.NG);
					}
				}else if(i == 10){	//读IMMO状态
					System.arraycopy(readbuf, 4,v_immo_status,0,4);
					if((v_immo_status[1]) != 0){
						showProcessList("IMMO已学过",Common.NULL,Common.OK);
						//						break;
					}
				}else if(i == 17){ //读取钥匙数量
					System.arraycopy(readbuf, 4,v_immo_status,0,4);
					key_num = (v_immo_status[1] >> 3) & 0x07; //关联的钥匙数量
					if(key_num > 0){
						showProcessList(key_num+"把",Common.NULL,Common.OK);
						i = 24;
						continue;
					}
				}else if(i == 11 || i == 47){ //读转发器状态
					System.arraycopy(readbuf, 4,v_trans_status,0,4);
					int Result = 1;
					String status;
					if((v_trans_status[0] & 0x01) == 0x01) //防盗线圈故障
						status="Ring:1;";
					else{
						status="Ring:0;";
						Result = 2;
					}
					if(((v_trans_status[0] >> 3) & 0x01) == 0x01) //new
						status+="New:0;";
					else
						status+="New:1;";
					if(((v_trans_status[0] >> 4) & 0x01) == 0x01) //SK
						status+="SK:1;";
					else
						status+="SK:0;";
					showProcessList(status,Common.NULL,Result == 2 ? Common.NG : Common.OK);
				}else if(i==58){
					System.arraycopy(readbuf, 4,v_trans_status,0,4);
					if(((v_trans_status[0]>>1) & 0x01) == 0x01) continue;
					i = 64;
				}else if(i == 4 || i == 12 || i == 19 || i == 27 || i == 33 || i == 37 || i == 49 || i == 60  || i == 72 || i == 83 || i == 92){ //获取SEED
					System.arraycopy(readbuf, 3, seed, 0, 8);
				}else if(i == 15 || i == 30){ //读VIN,显示
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					showProcessList(new String(vin),new String(vin),Common.OK);
				}else if(i == 21 || i == 39 || i == 51 || i == 62 || i == 74 || i == 85){ //学习钥匙
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1500);
				}else if(i == 22 || i == 40 || i == 52 || i == 63 || i == 75 || i  == 86){ //15检查钥匙学习结果,33检查EMS学习SK情况,45key2,63tcu,68 immo teach tcu,77immo teach escl
					if(readbuf[5] == 0x01 || readbuf[5] == 0x03){ //继续
						if(i == 63) continue;
						Commonfunc.sleep(500);
						i --;
					}else if(readbuf[5] == 0x02) {//OK
						showProcessList("OK",Common.NULL,Common.OK);
					}else if(readbuf[5] == 0x04){ //stop
						showProcessList("Routine stopped!",Common.NULL,Common.NG);
						break;
					}else{	//stop
						showProcessList("Routine failure and routine not run!",Common.NULL,Common.NG);
						break;
					}
				}else if(i == 24){ //检查转发器状态
					System.arraycopy(readbuf, 4,v_trans_status,0,4);
					if((v_trans_status[0] & 0x10) == 0x10) //已经配对
						showProcessList("",Common.NULL,Common.OK);
					else{
						showProcessList(readbuf[5]+"",Common.NULL,Common.NG);
					}
				}else if(i == 26 || i == 32){ //读取EMS状态
					System.arraycopy(readbuf, 4,v_ems_status,0,4);
					String status;
					if(((v_ems_status[1] >> 1) & 0x01) == 0x01) //VIN
						status="VIN:1;";
					else
						status="VIN:0;";
					if(((v_ems_status[1] >> 2) & 0x01) == 0x01) //PIN
						status+="PIN:1;";
					else
						status+="PIN:0;";
					if(((v_ems_status[1] >> 3) & 0x01) == 0x01) //SK
						status+="SK:1;";
					else
						status+="SK:0;";
					showProcessList(status,Common.NULL,Common.OK);
					if(i == 32){
						if(((v_ems_status[1] >> 1) & 0x07) == 0x07){ //EMS已经学习过
							i = 43;
							continue;
						}
					}
				}else if(i == 43){ //EMS状态,SK学习结果
					System.arraycopy(readbuf, 4,v_ems_status,0,4);
					if(((v_ems_status[1] >> 1) & 0x07) == 0x07) //EMS已经学习过
						showProcessList("VIN/PIN/SK",Common.NULL,Common.OK);
					else{
						showProcessList("SK",Common.NULL,Common.NG);
					}
				}else if(i == 45){ //key off
					System.arraycopy(readbuf, 4,v_immo_status,0,4);//第3次01 08
					int nu = (v_immo_status[1] >> 3) & 0x07; //关联的钥匙数量
					if(nu > 1){
						i = 54;
						continue;
					}
					if((v_immo_status[0] & 0x01) == 0x01){ //ON
						showTip("KEY OFF...");
						Commonfunc.sleep(100);
						i --;
					}
				}else if(i == 46){ //检查KEY ON
					System.arraycopy(readbuf, 4,v_immo_status,0,4);//第四次
					if((v_immo_status[0] & 0x01) == 0x00){ //ON
						showTip("KEY ON...");
						Commonfunc.sleep(100);
						i --;
					}
				}else if(i == 79){ //key off
					System.arraycopy(readbuf, 4,v_immo_status,0,4);
					if((v_immo_status[0] & 0x01) == 0x01){ //ON
						showTip("切换至ACC档...");
						Commonfunc.sleep(500);
						i --;
					}
				}else if(i == 90){//KEY ON
					System.arraycopy(readbuf, 4,v_immo_status,0,4);
					if((v_immo_status[0] & 0x01) == 0x00){ //0FF
						showTip("开钥匙KEY ON...");
						Commonfunc.sleep(500);
						i --;
					}else{ //等10秒
						for(int k = 2; k >= 0; k --){
							showTip("等待:"+k+"s");
							Commonfunc.sleep(1000);
						}
					}
				}else if(i == 67){ //检查钥匙数量
					System.arraycopy(readbuf, 4,v_immo_status,0,4);
					key_num = (v_immo_status[1] >> 3) & 0x07; //关联的钥匙数量
					boolean v_isc =false;
					if(cartype.getMap("BM")>0)
						v_isc = true;
					if(key_num == 2){ //OK
						showProcessList("2把",Common.NULL,Common.OK);
					}else if(key_num == 3 && v_isc){ //OK
						showProcessList("3把",Common.NULL,Common.OK);
					}else{
						showProcessList(key_num+"把",Common.NULL,Common.NG);
						break;
					}
				}else if(i == 78){ //检查TCU状态结果
					System.arraycopy(readbuf, 4,v_tcu_status,0,3);
					if(v_tcu_status[0] != 0x0F){ //不OK
						showProcessList(("TCU authentication failure!"),Common.NULL,Common.NG);
					}else
						showProcessList(("TCU OK!"),Common.NULL,Common.OK);
				}else if(i == 81){ //ESCL学习结果
					System.arraycopy(readbuf, 4,v_escl_status,0,1);
					if(v_escl_status[0] != 0x00){ //不OK
						showProcessList("ESCL 已经学习过!",Common.NULL,Common.OK);
						i = 88;
						continue;
					}else
						showProcessList("TSCL 开始学习!",Common.NULL,Common.OK);
				}else if(i == 88){//ESCL学习结果
					System.arraycopy(readbuf, 4,v_escl_status,0,1);
					if(v_escl_status[0] != 0x01){ //不OK
						showProcessList("ESCL authentication failure",Common.NULL,Common.NG);
					}else
						showProcessList("TSCL OK!",Common.NULL,Common.OK);
				}else if(i == 95){ //学习结果
					if(readbuf[5] == 0x01 || readbuf[5] == 0x03){ //继续
						i --;
						Commonfunc.sleep(1000);
					}else if(readbuf[5] == 0x02)
						showProcessList("OK",Common.NULL,Common.OK);
					else{
						showProcessList("执行失败",Common.NULL,Common.OK);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}else if(stepType.substring(0, 3).equals("SHW")){ //SHW
				//handlerSHW(stepType, true);
			}
		}
	}

	private void fun_T1P_PEPS1(Section section){
		if(!getpin()){
			showProcessList("未获取到PIN..",Common.NULL,Common.NG);
			return;
		}
		byte [] v_escl_status =new byte[10];	//ESCL状态
		byte [] v_tcu_status = new byte[10];	//TCU状态
		byte [] v_immo_status =new byte[10];	//IMMO状态
		byte [] v_ems_status = new byte[10];	//EMS状态
		byte [] v_trans_status = new byte[10];	//转发器状态
		int bcm_time = 6;
		boolean veleo = false;
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			if(i==79){
				int escl=(cartype.byteConfig[2]>>5)&0x07;
				if( escl!=0x00 && escl!=0x01)//只有变速箱类型为5MT和6MT时才做ESCL
					break;
			}
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){
				int cmdlen = Commonfunc.hexStringtoInt(stepType.substring(4, 6));
				byte [] cmd = new byte[cmdlen + 1];
				if(Commonfunc.CmdStringToBytes(stepType.substring(4), cmd, cmdlen + 1) > cmd.length) return;
				//---------------------发送前处理---------------------
				if(i == 1){
					if (cartype.getMap("BM")>0 || veleo){
						if(!SetCanInitial("PEPS1",canid)) return;
					}else{
						if(!SetCanInitial("BCM1",canid)) return;
					}
				}else if(i == 9 || i == 36 || i == 44 || i == 71 || i == 79 || i == 82 || i == 89){		//切换至IMMO
					if(!SetCanInitial("IMMO1",canid)) return;
				}else if(i == 25 || i == 42){	//切换至EMS
					if(!SetCanInitial("EMS1",canid)) return;
				}else if(i == 68 || i == 77){ //切换至TCU
					if(!SetCanInitial("TCU1",canid))return;
				}else if(i == 2 || i == 80 || i == 88 || i == 91){ //切换至PEPS
					if(!SetCanInitial("PEPS1",canid))return;
				}else if(i == 5 || i == 13 || i == 28 || i == 93){ //安全认证1
					if(seed[0] == 0) continue;
					Security.CX62_IMMO_Safekey(seed, key,0);
					System.arraycopy(key, 0, cmd, 3, 8);
				}else if (i == 6){
					System.arraycopy(cartype.byteConfig, 0, cmd, 4, cmd[0]-3);
				}else if(i == 20 || i == 34 || i == 38 || i == 50 || i == 61 || i == 73 || i == 84){ //安全认证2
					if(seed[0] == 0) continue;
					int pin=(cartype.pin[0]&0xFF) * 0x1000000 + (cartype.pin[1]&0xFF) * 0x10000 +
							(cartype.pin[2]&0xFF) * 0x100 + (cartype.pin[3]&0xFF) * 0x01;
					Security.CX62_IMMO_Safekey(seed, key,pin);
					System.arraycopy(key, 0, cmd, 3, 8);
				}else if(i == 14 || i == 29){ //写VIN
					System.arraycopy(cartype.vin, 0, cmd, 4, 17);
				}else if(i == 16){ //IMMO写PIN
					if((v_immo_status[1] & 0x04) == 0x04){ //VIN、PIN已写
						continue;
					}
					System.arraycopy(cartype.pin, 0, cmd, 4, 4);
				}else if(i == 31){ //EMS写PIN
					if(((v_ems_status[1] >> 2) & 0x01) == 0x01) continue;
					System.arraycopy(cartype.pin, 0, cmd, 4, 4);
				}else if(i == 47){ //提示更换第二把钥匙
					for(int kk = bcm_time; kk >= 0; kk --){
						showTip("更换钥匙2.."+kk+"s");
						Commonfunc.sleep(1000);
					}
				}else if (i == 48 || i == 59){
					if((v_trans_status[0] & 0x01) != 0x01){ //防盗线圈故障
						break;
					}
				}else if(i == 58){ //提示更换第3把钥匙
//					if((cartype.byteConfig[4]&0x40)==0 || key_num == 3){//没有BM则不学习第三把钥匙
					i = 66 ;
					continue;
//					}
//					bcm_time = 6;
//					for(int kk = bcm_time; kk >= 0; kk --){
//						showTip("更换钥匙3.."+kk+"s");
//						Commonfunc.sleep(1000);
//						if((kk % 2) == 0){
//							bluetooth.canSendAndRecvN2N(keep, readbuf, Common.CMD_MAX_TIME);
//						}
//					}
				}else if(i == 24 || i == 54 || i == 64){
					Commonfunc.sleep(1500);
				}

//				error = bluetooth.canSendAndRecvN2N(cmd, readbuf, Common.CMD_MAX_TIME);
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);

				if(error == 5001){
					if(i == 1  && !veleo){
						veleo = true;
						i--;
					}
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}
				else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					if(i == 1  && !veleo){
						veleo = true;
						i--;
					}
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if(i == 1  && !veleo){
						veleo = true;
						i--;
					}
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}

				if(i == 1){//KEY ON,后等待10秒
					if(((readbuf[4] >> 3) & 0x01) == 0x01){ //ON		//
						for(int k = 2; k >= 0; k --){
							showTip("KEY ON  等待" + k + "s");
							Commonfunc.sleep(1000);
						}
					}else{
						showTip("请打开钥匙...");
						Commonfunc.sleep(1000);
						i --;
					}
				}else if(i == 7){
					Commonfunc.sleep(1000);
				}else if(i == 8){ //读VIN,显示
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					byte[] config = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(cartype.byteConfig, 0, config, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, config)){
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.NG);
					}
				}else if(i == 10){	//读IMMO状态
					System.arraycopy(readbuf, 4,v_immo_status,0,4);
					if((v_immo_status[1]) != 0){
						showProcessList("IMMO已学过",Common.NULL,Common.OK);
						//						break;
					}
				}else if(i == 17){ //读取钥匙数量
					System.arraycopy(readbuf, 4,v_immo_status,0,4);
					key_num = (v_immo_status[1] >> 3) & 0x07; //关联的钥匙数量
					if(key_num > 0){
						showProcessList(key_num+"把",Common.NULL,Common.OK);
						i = 24;
						continue;
					}
				}else if(i == 11 || i == 47){ //读转发器状态
					System.arraycopy(readbuf, 4,v_trans_status,0,4);
					int Result = 1;
					String status;
					if((v_trans_status[0] & 0x01) == 0x01) //防盗线圈故障
						status="Ring:1;";
					else{
						status="Ring:0;";
						Result = 2;
					}
					if(((v_trans_status[0] >> 3) & 0x01) == 0x01) //new
						status+="New:0;";
					else
						status+="New:1;";
					if(((v_trans_status[0] >> 4) & 0x01) == 0x01) //SK
						status+="SK:1;";
					else
						status+="SK:0;";
					showProcessList(status,Common.NULL,Result == 2 ? Common.NG : Common.OK);
				}else if(i==58){
					System.arraycopy(readbuf, 4,v_trans_status,0,4);
					if(((v_trans_status[0]>>1) & 0x01) == 0x01) continue;
					i = 64;
				}else if(i == 4 || i == 12 || i == 19 || i == 27 || i == 33 || i == 37 || i == 49 || i == 60  || i == 72 || i == 83 || i == 92){ //获取SEED
					System.arraycopy(readbuf, 3, seed, 0, 8);
				}else if(i == 15 || i == 30){ //读VIN,显示
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					showProcessList(new String(vin),new String(vin),Common.OK);
				}else if(i == 21 || i == 39 || i == 51 || i == 62 || i == 74 || i == 85){ //学习钥匙
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1500);
				}else if(i == 22 || i == 40 || i == 52 || i == 63 || i == 75 || i  == 86){ //15检查钥匙学习结果,33检查EMS学习SK情况,45key2,63tcu,68 immo teach tcu,77immo teach escl
					if(readbuf[5] == 0x01 || readbuf[5] == 0x03){ //继续
						if(i == 63) continue;
						Commonfunc.sleep(500);
						i --;
					}else if(readbuf[5] == 0x02) {//OK
						showProcessList("OK",Common.NULL,Common.OK);
					}else if(readbuf[5] == 0x04){ //stop
						showProcessList("Routine stopped!",Common.NULL,Common.NG);
						break;
					}else{	//stop
						showProcessList("Routine failure and routine not run!",Common.NULL,Common.NG);
						break;
					}
				}else if(i == 24){ //检查转发器状态
					System.arraycopy(readbuf, 4,v_trans_status,0,4);
					if((v_trans_status[0] & 0x10) == 0x10) //已经配对
						showProcessList("",Common.NULL,Common.OK);
					else{
						showProcessList(readbuf[5]+"",Common.NULL,Common.NG);
					}
				}else if(i == 26 || i == 32){ //读取EMS状态
					System.arraycopy(readbuf, 4,v_ems_status,0,4);
					String status;
					if(((v_ems_status[1] >> 1) & 0x01) == 0x01) //VIN
						status="VIN:1;";
					else
						status="VIN:0;";
					if(((v_ems_status[1] >> 2) & 0x01) == 0x01) //PIN
						status+="PIN:1;";
					else
						status+="PIN:0;";
					if(((v_ems_status[1] >> 3) & 0x01) == 0x01) //SK
						status+="SK:1;";
					else
						status+="SK:0;";
					showProcessList(status,Common.NULL,Common.OK);
					if(i == 32){
						if(((v_ems_status[1] >> 1) & 0x07) == 0x07){ //EMS已经学习过
							i = 43;
							continue;
						}
					}
				}else if(i == 43){ //EMS状态,SK学习结果
					System.arraycopy(readbuf, 4,v_ems_status,0,4);
					if(((v_ems_status[1] >> 1) & 0x07) == 0x07) //EMS已经学习过
						showProcessList("VIN/PIN/SK",Common.NULL,Common.OK);
					else{
						showProcessList("SK",Common.NULL,Common.NG);
					}
				}else if(i == 45){ //key off
					System.arraycopy(readbuf, 4,v_immo_status,0,4);//第3次01 08
					int nu = (v_immo_status[1] >> 3) & 0x07; //关联的钥匙数量
					if(nu > 1){
						i = 54;
						continue;
					}
					if((v_immo_status[0] & 0x01) == 0x01){ //ON
						showTip("KEY OFF...");
						Commonfunc.sleep(100);
						i --;
					}
				}else if(i == 46){ //检查KEY ON
					System.arraycopy(readbuf, 4,v_immo_status,0,4);//第四次
					if((v_immo_status[0] & 0x01) == 0x00){ //ON
						showTip("KEY ON...");
						Commonfunc.sleep(100);
						i --;
					}
				}else if(i == 79){ //key off
					System.arraycopy(readbuf, 4,v_immo_status,0,4);
					if((v_immo_status[0] & 0x01) == 0x01){ //ON
						showTip("切换至ACC档...");
						Commonfunc.sleep(500);
						i --;
					}
				}else if(i == 90){//KEY ON
					System.arraycopy(readbuf, 4,v_immo_status,0,4);
					if((v_immo_status[0] & 0x01) == 0x00){ //0FF
						showTip("开钥匙KEY ON...");
						Commonfunc.sleep(500);
						i --;
					}else{ //等10秒
						for(int k = 2; k >= 0; k --){
							showTip("等待:"+k+"s");
							Commonfunc.sleep(1000);
						}
					}
				}else if(i == 67){ //检查钥匙数量
					System.arraycopy(readbuf, 4,v_immo_status,0,4);
					key_num = (v_immo_status[1] >> 3) & 0x07; //关联的钥匙数量
					boolean v_isc =false;
					if(cartype.getMap("BM")>0)
						v_isc = true;
					if(key_num == 2){ //OK
						showProcessList("2把",Common.NULL,Common.OK);
					}else if(key_num == 3 && v_isc){ //OK
						showProcessList("3把",Common.NULL,Common.OK);
					}else{
						showProcessList(key_num+"把",Common.NULL,Common.NG);
						break;
					}
				}else if(i == 78){ //检查TCU状态结果
					System.arraycopy(readbuf, 4,v_tcu_status,0,3);
					if(v_tcu_status[0] != 0x0F){ //不OK
						showProcessList(("TCU authentication failure!"),Common.NULL,Common.NG);
					}else
						showProcessList(("TCU OK!"),Common.NULL,Common.OK);
				}else if(i == 81){ //ESCL学习结果
					System.arraycopy(readbuf, 4,v_escl_status,0,1);
					if(v_escl_status[0] != 0x00){ //不OK
						showProcessList("ESCL 已经学习过!",Common.NULL,Common.OK);
						i = 88;
						continue;
					}else
						showProcessList("TSCL 开始学习!",Common.NULL,Common.OK);
				}else if(i == 88){//ESCL学习结果
					System.arraycopy(readbuf, 4,v_escl_status,0,1);
					if(v_escl_status[0] != 0x01){ //不OK
						showProcessList("ESCL authentication failure",Common.NULL,Common.NG);
					}else
						showProcessList("TSCL OK!",Common.NULL,Common.OK);
				}else if(i == 95){ //学习结果
					if(readbuf[5] == 0x01 || readbuf[5] == 0x03){ //继续
						i --;
						Commonfunc.sleep(1000);
					}else if(readbuf[5] == 0x02)
						showProcessList("OK",Common.NULL,Common.OK);
					else{
						showProcessList("执行失败",Common.NULL,Common.OK);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}else if(stepType.substring(0, 3).equals("SHW")){ //SHW
				handlerSHW(stepType,"请更换钥匙2......", true);
			}
		}
	}


	private void fun_CX62_BCM1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		int time=10;
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){ //安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}else if(i == 5){ //
					System.arraycopy(cartype.byteConfig, 0, cmd, 4, cmd[0] - 3);
				}else if(i == 8){ //决定是否要做遥控钥匙匹配
					if(cartype.getMap("PEPS") > 0){
						i = 11;
						continue;
					}
				}else if(i == 9){
					showTip("按开/闭锁键学习遥控..." + time + "S");
				}
				///////////////////////命令发送////////////////////////////////
//				error = bluetooth.canSendAndRecvN2N(cmd, readbuf, Common.CMD_MAX_TIME);
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				//错误处理
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				//特殊处理返回结果
				if(i == 3){	//读seed
					System.arraycopy(readbuf, 3, seed, 0, 2);
				}else if(i == 6){ //复位
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				}else if(i == 7){ //读配置
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					byte [] config = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(cartype.byteConfig,0,config,0,(readbuf[0]&0xFF) - 3);
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, config)){
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL, Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL, Common.NG);
					}
				}else if(i == 9){ //查询遥控钥匙学习结果
					if(readbuf[4] != 1){
						if(time > 0){
							i --;
							Commonfunc.sleep(900);
							time --;
						}
					}
				}else if(i == 11){ //读取学习数量
					if(readbuf[4] != 0x01){
						i = 7;
						time = 10;
						continue;
					}
					showProcessList(readbuf[4] + "把",Common.NULL,Common.OK);
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_Q22LEV_BCM1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		int time = 10;
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){ //安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}else if(i == 5){ //
					System.arraycopy(cartype.byteConfig, 0, cmd, 4, cartype.byteConfig.length);
				}else if(i == 8){
					showTip("按开/闭锁键学习遥控..." + time + "S");
				}
				///////////////////////命令发送////////////////////////////////
//				error = bluetooth.canSendAndRecvN2N(cmd, readbuf, Common.CMD_MAX_TIME);
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				//错误处理
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				//特殊处理返回结果
				if(i == 3){	//读seed
					System.arraycopy(readbuf, 3, seed, 0, 2);
				}else if(i == 6){ //复位
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				}else if(i == 7){ //读配置
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.byteConfig)){
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL, Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL, Common.NG);
					}
				}else if(i == 9){ //查询遥控钥匙学习结果
					if(readbuf[4] != 1){
						if(time > 0){
							i --;
							Commonfunc.sleep(900);
							time --;
						}
					}
				}else if(i == 11){ //读取学习数量
					if(readbuf[4] != 0x01){
						i = 7;
						time = 10;
						continue;
					}
					showProcessList(readbuf[4] + "把",Common.NULL,Common.OK);
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_KQ92_BCM1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		int time = 10;
		String stime = section.get("KEY_TIME");
		if(stime != null)
			time = Integer.valueOf(stime);
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){ //安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}else if(i == 5){ //
					System.arraycopy(cartype.byteConfig, 0, cmd, 4, cartype.byteConfig.length);
				}else if(i == 8 )
				{
					showTip("按开/闭锁键学习遥控..." + time + "S");
				}
				///////////////////////命令发送////////////////////////////////
//				error = bluetooth.canSendAndRecvN2N(cmd, readbuf, Common.CMD_MAX_TIME);
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				//错误处理
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				//特殊处理返回结果
				if(i == 3){	//读seed
					System.arraycopy(readbuf, 3, seed, 0, 2);
				}else if(i == 6){ //读配置
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.byteConfig)){
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL, Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL, Common.NG);
					}
				}else if(i == 8)  //等待按钥匙
				{
					//等待

					if(readbuf[4] != 1){
						if(time > 0){
							i --;
							Commonfunc.sleep(900);
							time --;
						}
					}else{
						showProcessList(readbuf[4] + "把",Common.NULL,Common.OK);
					}
				}
				else if(i == 14)
				{

				}
				else if(i == 11){
					byte [] dtc = new byte[128];
					ArrayList<HashMap<String,String>> dtclist = new ArrayList<HashMap<String,String>>();
					dtc[0] = (byte) (((readbuf[0]&0xFF) - 3) / 4);
					System.arraycopy(readbuf, 4, dtc, 1, (dtc[0]&0xFF) * 4);
					dtclist = FileReader.readDtc(section.get("MODULE"), dtc, 2, false, false);
					if(dtclist.size() > 0){
						for(int z = 0; z < dtclist.size(); z ++){
							showProcessList(dtclist.get(z).get(Common.CONTENT),Common.NULL, Common.NG);
							mDtc.add(section.get("MODULE").substring(0, section.get("MODULE").length() - 1) + "--" + dtclist.get(z).get(Common.CONTENT));
						}
					}else{
						showProcessList("无故障",Common.NULL,Common.OK);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_CX62_BCM2(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){ //安全认证
					Security.CX62_IMMO_Safekey(seed, key, 0);
					System.arraycopy(key, 0, cmd, 3, 8);
				}else if(i == 5){ //
					System.arraycopy(cartype.byteConfig, 0, cmd, 4, cmd[0] - 3);
				}
				///////////////////////命令发送////////////////////////////////
//				error = bluetooth.canSendAndRecvN2N(cmd, readbuf, Common.CMD_MAX_TIME);
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				//错误处理
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i == 3){	//读seed
					System.arraycopy(readbuf,3,seed,0, 8);
				}else if(i == 6){ //复位
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				}else if(i == 7){ //读配置
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					byte [] config = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(cartype.byteConfig,0,config,0,(readbuf[0]&0xFF) - 3);
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, config)){
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.NG);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_T1N_write(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){ //安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}else if(i == 5){ //
					System.arraycopy(cartype.byteConfig, 0, cmd, 4,32);;
				}
				///////////////////////命令发送////////////////////////////////
//				error = bluetooth.canSendAndRecvN2N(cmd, readbuf, Common.CMD_MAX_TIME);
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i == 3){	//读seed
					System.arraycopy(readbuf,3,seed,0, 2);
				}else if(i == 6){ //复位
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				}else if(i == 7){ //读配置
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					byte [] vincode =new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(cartype.byteConfig,0,vincode,0,(readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, vincode)){
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.NG);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_T1P_BDM1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				int cmdlen = Commonfunc.hexStringtoInt(stepType.substring(4, 6));
				byte [] cmd = new byte[cmdlen + 1];
				if(Commonfunc.CmdStringToBytes(stepType.substring(4), cmd, cmdlen + 1) > cmd.length) return;
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){ //安全认证
					if(seed[0] == 0) continue;
					Security.CX62_IMMO_Safekey(seed, key,0);
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				}else if(i == 5){ //
					System.arraycopy(cartype.byteConfig, 0, cmd, 4,32);
				}
				///////////////////////命令发送////////////////////////////////
//				error = bluetooth.canSendAndRecvN2N(cmd, readbuf, Common.CMD_MAX_TIME);
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i == 3){	//读seed
					System.arraycopy(readbuf, 3, seed, 0, readbuf[0] - 2);
				}else if(i == 6){ //复位
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				}else if(i == 7){ //读配置
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					byte [] vincode =new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(cartype.byteConfig,0,vincode,0,(readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, vincode)) {
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.NG);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_T1P_ICM1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				int cmdlen = Commonfunc.hexStringtoInt(stepType.substring(4, 6));
				byte [] cmd = new byte[cmdlen + 1];
				if(Commonfunc.CmdStringToBytes(stepType.substring(4), cmd, cmdlen + 1) > cmd.length) return;
				///////////////////////命令发送前////////////////////////////////
				if(cmd[1] == 0x27 && cmd[2] == 0x04){ //安全认证
					if(seed[0] == 0) continue;
					Security.CX62_IMMO_Safekey(seed, key,0);
					System.arraycopy(key, 0, cmd, 3, 8);
				}else if(i == 5){ //
					System.arraycopy(cartype.byteConfig, 0, cmd, 4,32);
				}
				///////////////////////命令发送////////////////////////////////
//				error = bluetooth.canSendAndRecvN2N(cmd, readbuf, Common.CMD_MAX_TIME);
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(readbuf[1] == 0x67 && (readbuf[2] == 0x3)){	//读seed
					System.arraycopy(readbuf, 3, seed, 0, readbuf[0] - 2);
				}else if(i == 6){ //复位
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				}else if(i == 7){ //读配置
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					byte [] vincode =new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(cartype.byteConfig,0,vincode,0,(readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, vincode)) {
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.NG);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}


	private void fun_CX62_ICM1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(cmd[1] == 0x027 && (cmd[2] == 0x02 || cmd[2] == 0x04)){ //安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}else if(cmd[1] == 0x02E){
					int sid = (cmd[2]&0xFF) * 0x100 + (cmd[3]&0xFF);
					switch (sid)
					{
						case 0xD009:
						case 0x3011:
							System.arraycopy(cartype.byteConfig, 0, cmd, 4,cmd[0] - 3);
							break;
						case 0xF190:
							System.arraycopy(cartype.vin, 0, cmd, 4,cmd[0] - 3);
							break;
					}
				}
				///////////////////////命令发送////////////////////////////////
//				error = bluetooth.canSendAndRecvN2N(cmd, readbuf, Common.CMD_MAX_TIME);
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(cmd[1] == 0x027 && (cmd[2] == 0x01 || cmd[2] == 0x03)){	//读seed
					System.arraycopy(readbuf,3,seed,0, readbuf[0] - 2);
				}else if(cmd[1] == 0x11){ //复位
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				}else if(readbuf[1] == 0x62){ //读配置
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					byte [] config = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(cartype.byteConfig,0,config,0,(readbuf[0]&0xFF) - 3);
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, config)){
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.NG);
					}
				}else if(readbuf[1] == 0x6E)
				{
					showProcessList(Commonfunc.bytesToHexString(cmd, 4, cmd[0] - 3),Common.NULL,Common.OK);
					Commonfunc.sleep(1000);
				}
				else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_CX62B_SMM_WRITE1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){ //安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i == 3){	//读seed
					System.arraycopy(readbuf,3,seed,0, 2);
				}else if(i == 5){ //复位
					if((readbuf[5]&0xFF) == 0xFF){
						showProcessList("初始化成功",Common.NULL,Common.OK);
					}else if((readbuf[5]&0xFF) == 1){
						showProcessList("初始化失败",Common.NULL,Common.NG);
					}else if((readbuf[5]&0xFF) == 2){
						showProcessList("正在初始化...",Common.NULL,Common.OK);
						Commonfunc.sleep(2500);
						i --;
					}
				}else if(i == 6){ //复位
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1000);
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_CX62B_SMM_READ1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){ //安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i == 3){	//读seed
					System.arraycopy(readbuf,3,seed,0, 2);
				}else if(i == 5){ //复位
					if((readbuf[5]&0xFF) == 0xFF){
						showProcessList("正在初始化",Common.NULL,Common.OK);
					}else{
						showProcessList("初始化失败",Common.NULL,Common.NG);
					}
				}else if(i == 6){ //复位
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1000);
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_CX62B_TCM1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		byte [] config = cartype.getWriteByte("TCU");
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){ //安全认证
					if(cmd[0] == 0x04)
						Security.hefei_BCM_safekey(seed, key);
					else
						Security.CX62B_TCM_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				}else if(i == 5){ //
					System.arraycopy(config, 0, cmd, 4, config.length);;
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i == 3){	//读seed
					System.arraycopy(readbuf,3,seed,0, readbuf[0] - 2);
				}else if(i == 6){ //复位
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				}else if(i == 7){ //读配置
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, config)){
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.NG);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_CX62B_GBC1(Section section){
		if(!SetCanInitial("TCU1",canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		byte [] config = new byte[8];
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				int cmdlen = Commonfunc.hexStringtoInt(stepType.substring(4, 6));
				byte [] cmd = new byte[cmdlen + 1];
				if(Commonfunc.CmdStringToBytes(stepType.substring(4), cmd, cmdlen + 1) > cmd.length) return;
				///////////////////////命令发送前////////////////////////////////
				if(i == 2){
					if(!SetCanInitial(section.get("MODULE"),canid)) return;
				}else if(i == 4){ //安全认证
					if(seed[0] == 0 && seed[1] == 0) continue;
					Security.CX62B_GBC_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}else if(i == 5){ //
					System.arraycopy(config, 0, cmd, 4, config.length);;
				}
				///////////////////////命令发送////////////////////////////////
				if(i == 6){
					error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME*5, 2);
				}else{
					error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				}
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i == 1){
					System.arraycopy(readbuf, 4, config , 0, 8);
					showProcessList(Commonfunc.bytesToHexString(config, 0, config.length),Common.NULL,Common.OK);
				}else if(i == 3){//读seed
					System.arraycopy(readbuf,3, seed,0, 2);
				}else if(i == 6){ //查询配置
					if (readbuf[5] == 0x03){
						showProcessList("写入成功",Common.NULL,Common.OK);
					}else{
						showProcessList("写入失败",Common.NULL,Common.NG);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_T1N_TPMS1(Section section){
		//获取胎压信息

		if (!GetTpmsfromWebservice()){
			if(Common.stationPos == 0)
			{
				showProcessList("获取胎压信息失败",Common.NULL, Common.NG);
				return;
			}
			else
			{
				showProcessList("获取胎压信息失败",Common.NULL, Common.NULL);
			}
		}
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);

				///////////////////////命令发送前////////////////////////////////
				if(i == 4){ //安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}
				if (cmd[1]==0x2E){//写
					int v_code = (cmd[2]&0xFF) * 0x100 + (cmd[3]&0xFF);
					switch (v_code){
						case 0x3400:   //tpms
							if((cartype.tpms[0] |cartype.tpms[1]) == 0)
							{
								showProcessList("获取TPMS FL_ID失败!",Common.NULL,Common.NG);
								m_com.m_log.PrintLog("获取TPMS FL_ID失败");
								continue;
							}
							else
								m_com.m_log.PrintLog("FL_ID:"+Commonfunc.bytesToHexStringP(cartype.tpms, 0, 4));
							System.arraycopy(cartype.tpms, 0, cmd, 4, cmd[0] - 3);
							break;
						case 0x3401:
							if((cartype.tpms[4] |cartype.tpms[5]) == 0)
							{
								showProcessList("获取TPMS FR_ID失败!",Common.NULL,Common.NG);
								m_com.m_log.PrintLog("获取TPMS FR_ID失败!");
								continue;
							}
							else
								m_com.m_log.PrintLog("FR_ID:" + Commonfunc.bytesToHexStringP(cartype.tpms, 4, 8));
							System.arraycopy(cartype.tpms, 4, cmd, 4, cmd[0] - 3);
							break;
						case 0x3402:
							if((cartype.tpms[8] |cartype.tpms[9]) == 0)
							{
								showProcessList("获取TPMS RL_ID失败!",Common.NULL,Common.NG);
								m_com.m_log.PrintLog("获取TPMS RL_ID失败!");
								continue;
							}
							else
								m_com.m_log.PrintLog("RL_ID:" + Commonfunc.bytesToHexStringP(cartype.tpms, 8, 12));
							System.arraycopy(cartype.tpms, 8, cmd, 4, cmd[0] - 3);
							break;
						case 0x3403:
							if((cartype.tpms[12] |cartype.tpms[13]) == 0)
							{
								showProcessList("获取TPMS RR_ID失败!",Common.NULL,Common.NG);
								m_com.m_log.PrintLog("获取TPMS RR_ID失败!");
								continue;
							}
							else
								m_com.m_log.PrintLog("RR_ID:" + Commonfunc.bytesToHexStringP(cartype.tpms, 12, 16));
							System.arraycopy(cartype.tpms, 12, cmd, 4, cmd[0] - 3);
							break;
					}
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i == 3){	//读seed
					System.arraycopy(readbuf,3, seed,0, 2);
				}else if(readbuf[1] == 0x62)
				{ //读ID
					if((readbuf[3]&0xFF) < 4)
					{
						byte[] v_data = new byte[readbuf[0] - 3];
						byte [] v_tpms = new byte[4];
						System.arraycopy(cartype.tpms,(int)(readbuf[3]*4),v_tpms,0,4);
						System.arraycopy(readbuf, 4, v_data, 0, readbuf[0] - 3);
						if(Commonfunc.bytesCompare(v_data,v_tpms) == 1)
							showProcessList(Commonfunc.bytesToHexString(v_data, 0, v_data.length),Commonfunc.bytesToHexString(v_tpms, 0, v_tpms.length),Common.OK);
						else {
							//handlerSHW("SHW:NO<0>","读取胎压ID与服务器不一致。请线下返工手动确认！！！", true);
							showProcessList(Commonfunc.bytesToHexString(v_data, 0, v_data.length), Commonfunc.bytesToHexString(v_tpms, 0, v_tpms.length), Common.NULL);
						}
					}
				}else if(readbuf[1] == 0x6E){//读状态
					showProcessList(Commonfunc.bytesToHexString(cmd, 4, 4),"写入成功",Common.OK);
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_CX62_BM1(Section section){
		if(!getpin()){
			showProcessList("未获取到PIN码",Common.NULL,Common.NG);
			return;
		}
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(cmd[1] == 0x27 && cmd[2] == 0x04){ //安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}else if(cmd[1] == 0x2E && (cmd[2]&0xFF) == 0xF1 && (cmd[2]&0xFF) == 0x90){ //
					System.arraycopy(cartype.vin, 0, cmd, 4, 17);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(cmd[1] == 0x27 && cmd[2] == 0x03){	//读seed
					System.arraycopy(readbuf,3,seed,0, 2);
				}else if(cmd[1] == 0x11){ //复位
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				}else if(cmd[1] == 0x22 && (cmd[2]&0xFF) == 0xF1 && (cmd[2]&0xFF) == 0x90){ //读VIN
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.vin)){
						showProcessList(new String(vin),new String(cartype.vin),Common.OK);
					}else{
						showProcessList(new String(vin),new String(cartype.vin),Common.NG);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}



	private void fun_PHEV_TBOX1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		byte [] config = cartype.byteConfig;
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){//安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}else if(i == 5){ //写配置
					System.arraycopy(cartype.byteConfig, 0, cmd, 4,40);
				}else if(i == 6){ //写vin
					System.arraycopy(cartype.vin, 0, cmd, 4, 17);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i ==3){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, 2);
				}else if(i==7){
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(5000);
				}else if(i == 9){ //读配置
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					byte [] vincode =new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(cartype.byteConfig,0,vincode,0,(readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, vincode)) {
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.NG);
					}
				}else if(i == 10){ //读VIN
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.vin)){
						showProcessList(new String(vin),new String(cartype.vin), Common.OK);
					}else{
						showProcessList(new String(vin),new String(cartype.vin), Common.NG);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}
	private void fun_PHEV_MUDULE1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		byte [] config = cartype.byteConfig;
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){//安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}else if(i == 5){ //写配置
					System.arraycopy(cartype.byteConfig, 0, cmd, 4,32);
				}else if(i == 6){ //写vin
					System.arraycopy(cartype.vin, 0, cmd, 4, 17);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i ==3){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, 2);
				}else if(i==7){
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				}else if(i == 8){ //读配置
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					byte [] vincode =new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(cartype.byteConfig,0,vincode,0,(readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, vincode)) {
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.NG);
					}
				}else if(i == 9){ //读VIN
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.vin)){
						showProcessList(new String(vin),Common.NULL, Common.OK);
					}else{
						showProcessList(new String(vin),Common.NULL, Common.NG);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}


	private void fun_CX62_TBOX1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		//byte [] config = cartype.byteConfig;
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){//安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}else if(i == 5){ //写配置
					System.arraycopy(cartype.byteConfig, 0, cmd, 4,cmd[0] - 3);;
				}else if(i == 6){ //写vin
					System.arraycopy(cartype.vin, 0, cmd, 4, 17);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						if(i == 5 || i == 8) continue;
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i ==3){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, 2);
				}else if(i==7){
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				}else if(i == 8){ //读配置
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					byte [] config = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(cartype.byteConfig,0,config,0,(readbuf[0]&0xFF) - 3);
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(config, vin)){
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.NG);
					}
				}else if(i == 9){ //读VIN
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.vin)){
						showProcessList(new String(vin),Common.NULL, Common.OK);
					}else{
						showProcessList(new String(vin),Common.NULL, Common.NG);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_Q22LEV_VCU1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){//安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}else if(i == 5){ //写vin
					System.arraycopy(cartype.vin, 0, cmd, 4, 17);
				}else if(i == 7){ //写配置
					System.arraycopy(cartype.byteConfig, 0, cmd, 4, cartype.byteConfig.length);;
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i ==3){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, 2);
				}else if(i == 6){ //读VIN
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.vin)){
						showProcessList(new String(vin),Common.NULL, Common.OK);
					}else{
						showProcessList(new String(vin),Common.NULL, Common.NG);
					}
				}else if(i == 8){ //读配置
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(cartype.byteConfig, vin)){
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.NG);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_KX63_TBOX1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4 || i == 12){//安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}else if(i == 5){ //写配置
					System.arraycopy(cartype.byteConfig, 0, cmd, 4,cartype.byteConfig.length);;
				}else if(i == 6){ //写vin
					System.arraycopy(cartype.vin, 0, cmd, 4, 17);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i == 3 || i == 11){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, 2);
				}else if(i==7){
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				}else if(i == 8){ //读配置
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(cartype.byteConfig, vin)){
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.NG);
					}
				}else if(i == 9){ //读VIN
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.vin)){
						showProcessList(new String(vin),Common.NULL, Common.OK);
					}else{
						showProcessList(new String(vin),Common.NULL, Common.NG);
					}
				}else if (i == 14){
					if(readbuf[5] == 0x03){ //运行
						showProcessList("正在连接...",Common.NULL,Common.OK);
						Commonfunc.sleep(500);
						i --;
						continue;
					}else if(readbuf[5] == 0x02){
						showProcessList("连接成功",Common.NULL,Common.OK);
					}else if(readbuf[5] == 0x05){
						showProcessList("连接失败",Common.NULL,Common.NG);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}


	private void fun_Q22LEV_TBOX1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4 || i == 12){//安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}else if(i == 5){ //写配置
					System.arraycopy(cartype.byteConfig, 0, cmd, 4,cartype.byteConfig.length);;
				}else if(i == 6){ //写vin
					System.arraycopy(cartype.vin, 0, cmd, 4, 17);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i == 3 || i == 11){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, 2);
				}else if(i==7){
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				}else if(i == 8){ //读配置
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(cartype.byteConfig, vin)){
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.NG);
					}
				}else if(i == 9){ //读VIN
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.vin)){
						showProcessList(new String(vin),Common.NULL, Common.OK);
					}else{
						showProcessList(new String(vin),Common.NULL, Common.NG);
					}
				}else if (i == 14){
					if(readbuf[5] == 0x03){ //运行
						showProcessList("正在连接...",Common.NULL,Common.OK);
						Commonfunc.sleep(500);
						i --;
						continue;
					}else if(readbuf[5] == 0x02){
						showProcessList("连接成功",Common.NULL,Common.OK);
					}else if(readbuf[5] == 0x05){
						showProcessList("连接失败",Common.NULL,Common.NG);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_KM23_BCM1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){ //安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}else if(i == 5){ //
					System.arraycopy(cartype.byteConfig, 0, cmd, 4,cartype.byteConfig.length);;
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				//错误处理
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i == 3){	//读seed
					System.arraycopy(readbuf,3,seed,0, 2);
				}else if(i == 6){ //复位
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				}else if(i == 7){ //读配置
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.byteConfig)){
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.NG);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_K50EV_VCU1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){ //安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}else if(i == 5){ //
					System.arraycopy(cartype.vin, 0, cmd, 3, 17);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				//错误处理
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i == 3){	//读seed
					System.arraycopy(readbuf,3, seed, 0, 2);
				}else if(i == 7){ //读vin
					byte [] vin = new byte[(readbuf[0]&0xFF) - 2];
					System.arraycopy(readbuf, 3, vin, 0, (readbuf[0]&0xFF) - 2);
					if(Arrays.equals(vin, cartype.vin)){
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.NG);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_KM23_ABS1(Section section){
		byte [] config = cartype.getWriteByte("ABS");
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				int cmdlen = Commonfunc.hexStringtoInt(stepType.substring(4, 6));
				///////////////////////命令发送////////////////////////////////
				byte [] cmd = new byte[cmdlen];
				Commonfunc.cmdStringToBytes(stepType.substring(7), cmd);
				if(i == 5){ //安全认证
					Security.S32EV_ABS_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 5, 4);
				}else if(i == 6){ //
					System.arraycopy(config, 0, cmd, 5, config.length);
				}
				if(i == 1 || i == 8){
					error = bluetooth.kwpFastConnect(10400, 0, cmd,  readbuf, Common.CMD_MAX_TIME,  5004);
				}else{
					error = bluetooth.kwpOneToOne(cmd, readbuf, Common.CMD_MAX_TIME, 5004);
				}
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					if(i == 1){
						i++;
					}
					return;
				}else if(error > 0){//其他负响应
					showProcessList(Commonfunc.bytesToHexString(readbuf, 6, readbuf[1] + 1),Common.NULL, Common.NG);
					if(i == 1){
						i++;
					}
					continue;
				}
				if(i == 4){	//读seed
					System.arraycopy(readbuf, 8, seed, 0, 4);
				}else if(i == 9){ //读vin
					byte [] vin = new byte[config.length];
					System.arraycopy(readbuf, 8, vin, 0, config.length);
					if(Arrays.equals(vin, config)){
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.NG);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_K50EV_TBOX1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){//安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i == 3){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, 2);
				}else if (i == 6){
					if(readbuf[5] == 0x03){ //运行
						showProcessList("正在连接...",Common.NULL,Common.OK);
						Commonfunc.sleep(500);
						i --;
						continue;
					}else if(readbuf[5] == 0x02){
						showProcessList("连接成功",Common.NULL,Common.OK);
					}else if(readbuf[5] == 0x05){
						showProcessList("连接失败",Common.NULL,Common.NG);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_CX62B_DVR1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){//安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}else if(i == 5){ //写vin
					System.arraycopy(cartype.vin, 0, cmd, 4, 17);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i ==3){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, 2);
				}else if(i==6){
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				}else if(i == 7){ //读VIN
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.vin)){
						showProcessList(new String(vin),Common.NULL, Common.OK);
					}else{
						showProcessList(new String(vin),Common.NULL, Common.NG);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}


	private void fun_CX62B_FCM1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){//安全认证
					Security.CX62B_FCM_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 4);
				}else if(i == 5){ //写vin
					System.arraycopy(cartype.vin, 0, cmd, 4, 17);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i ==3){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, 4);
				}else if(i==6){
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				}else if(i == 7){ //读VIN
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.vin)){
						showProcessList(new String(vin),Common.NULL, Common.OK);
					}else{
						showProcessList(new String(vin),Common.NULL, Common.NG);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_CX62B_FRM1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){//安全认证
					Security.CX62B_FRM_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 4);
				}else if(i == 5){ //写vin
					System.arraycopy(cartype.vin, 0, cmd, 4, 17);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i ==3){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, 4);
				}else if(i==6){
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				}else if(i == 7){ //读VIN
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.vin)){
						showProcessList(new String(vin),Common.NULL, Common.OK);
					}else{
						showProcessList(new String(vin),Common.NULL, Common.NG);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_T1N_VIN61(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4)
				{//安全认证
					if(cmd[0] == 0x04)
						Security.Chery_Standard_Safekey(seed,key);
					else
						Security.S32EV_ABS_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				}
				else if(i == 5){ //写vin
					System.arraycopy(cartype.vin, 0, cmd, 4, 17);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i ==3){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, readbuf[0] - 2);
				}else if(i==6){
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				}else if(i == 7){ //读VIN
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.vin)){
						showProcessList(new String(vin),Common.NULL, Common.OK);
					}else{
						showProcessList(new String(vin),Common.NULL, Common.NG);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_T1N_BMS1(Section section){
		getheat(); //获取环境温度
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4)
				{//安全认证
					if(cmd[0] == 0x04)
						Security.Chery_Standard_Safekey(seed,key);
					else
						Security.S32EV_ABS_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				}
				else if(i == 5){ //写vin
					System.arraycopy(cartype.vin, 0, cmd, 4, 17);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i ==3){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, readbuf[0] - 2);
				}else if(i==6){
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				}else if(i == 7){ //读VIN
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.vin)){
						showProcessList(new String(vin),Common.NULL, Common.OK);
					}else{
						showProcessList(new String(vin),Common.NULL, Common.NG);
					}
				} else if (i==9) { //读绝缘电阻
					double readvalue=((((readbuf[4]&0xFF)*0x100)+(readbuf[5]&0xFF))*10)/1000;
					BigDecimal bDecimal = new BigDecimal(readvalue);
					bDecimal = bDecimal.setScale(2, BigDecimal.ROUND_HALF_UP);
					if (readvalue>1){
						String value=bDecimal+("MΩ");
						showProcessList(value,">1MΩ",Common.OK);
					}else {
						String value=bDecimal+("MΩ");
						showProcessList(value,">1MΩ",Common.NG);
					}
				} else if (i==10) { //读电芯最高温度
					int readvalue=((readbuf[4]&0xFF))-40;
					if (readvalue<45){
						String value=readvalue+"℃";
						showProcessList(value,"小于45℃",Common.OK);
					}else {
						String value=readvalue+"℃";
						showProcessList(value,"小于45℃",Common.NG);
					}
				} else if (i==11) { //读电芯最低温度
					int readvalue=((readbuf[4]&0xFF))-40;
					if (readvalue>-15){
						String value=readvalue+"℃";
						showProcessList(value,"大于-15℃",Common.OK);
					}else {
						String value=readvalue+"℃";
						showProcessList(value,"大于-15℃",Common.NG);
					}
					showProcessList(cartype.heat+"℃","环境温度",Common.NULL);
				} else if (i==12) { //读单体最高电压
					int readvalue=(((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF);
					if (readvalue<=4240){
						String value=readvalue+"mV";
						showProcessList(value,"小于或等于4240mV",Common.OK);
					}else {
						String value=readvalue+"mV";
						showProcessList(value,"小于或等于4240mV",Common.NG);
					}
				} else if (i==13) {  //读最低电压
					int readvalue=(((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF);
					if (readvalue>=3000){
						String value=readvalue+"mV";
						showProcessList(value,"大于或等于3000mV",Common.OK);
					}else {
						String value=readvalue+"mV";
						showProcessList(value,"大于或等于3000mV",Common.NG);
					}
				} else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_T1N_stand_module(Section section){
		String module = section.get("MODULE");
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		stepId = Integer.valueOf(section.get("MODULE_ID"));
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType == null && stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				for (int i1 = 0; i1 < cmd.length; i1++) {
				}
				showTip(stepName + "...");
				///////////////////////命令发送前////////////////////////////////
				if(cmd[1] == 0x27)
				{//安全认证
					if("FCM1".equals(module)){
						Security.CX62B_FCM_Safekey(seed, key);
					}
					else if(cmd[0] == 0x0A)
						Security.CX62_IMMO_Safekey(seed, key, 0);
					else if(cmd[0] == 0x04)
						Security.Chery_Standard_Safekey(seed,key);
					else{
						Security.S32EV_ABS_Safekey(seed, key);
					}
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				}
				else if(cmd[1]==0x11&&cmd[2]==0x01){
					if (section.get("MODULE").equals("EPS1")&&cartype.car.equals("T1NPHEV"))
						Commonfunc.sleep(300);
					else Commonfunc.sleep(100);
				}
				else if(cmd[1] == 0x2E){ //写vin
					int cmdid = (cmd[2]&0xFF) * 0x100 + (cmd[3]&0xFF);
					int adrpos = 0;
					switch (cmdid)
					{
						case 0xF190:
							System.arraycopy(cartype.vin, 0, cmd, 4, 17);
							break;
						case 0xD009:
						case 0x3011:
							if("AMP1".equals(module))
								adrpos = 116;
							else if("IHU1".equals(module))
								adrpos = 66;
							else if("RFR1".equals(module))
								adrpos = 127;
							else if("TBOX1".equals(module))
								adrpos = 36;
							else if("CLM1".equals(module))
								adrpos = 98;
							System.arraycopy(cartype.byteConfig, adrpos, cmd, 4, cmd[0] -3);
							break;
						case 0xD008:  //PIN
							System.arraycopy(cartype.pin, 0, cmd, 4, cmd[0] -3);
							break;
					}

				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(readbuf[1] == 0x67){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, readbuf[0] - 2);
				}else if(readbuf[1] == 0x51){
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(2000);
				}
				else if (readbuf[1]==0x62) {  //读数据
					byte [] v_data = new byte[readbuf[0] - 3];
					System.arraycopy(readbuf, 4, v_data, 0, readbuf[0] - 3);
					String v_show = "";
					String v_get = "";
					String v_get1 = "";
					double readvalue= 0;
					boolean isver = false;
					int v_code = (readbuf[2]&0xFF) * 0x100 + (readbuf[3]&0xFF);
					switch(v_code)
					{
						case 0xF190:
							if(stepName.indexOf("校验") >= 0)
							{
								if(Arrays.equals(v_data, cartype.vin)) {
									showProcessList(new String(v_data), new String(cartype.vin), Common.OK);
									i += 2;continue;
								}
							}
							else if(Arrays.equals(v_data, cartype.vin)){
							showProcessList(new String(v_data),new String(cartype.vin), Common.OK);
							}else
							{
								showProcessList(new String(v_data),new String(cartype.vin), Common.NG);
							}
							break;
						case 0xD009:
						case 0x3011:
							v_show = Commonfunc.bytesToHexString(v_data, 0, v_data.length);
							int adrpos = 0;
							if("AMP1".equals(module))
								adrpos = 116;
							else if("IHU1".equals(module))
								adrpos = 66;
							else if("RFR1".equals(module))
								adrpos = 127;
							else if("TBOX1".equals(module))
								adrpos = 36;
							else if("CLM1".equals(module))
								adrpos = 98;
							if(Commonfunc.Bequals(v_data, cartype.byteConfig,adrpos)){
								showProcessList(v_show,Commonfunc.bytesToHexStringP(cartype.byteConfig,adrpos,v_data.length), Common.OK);
							}else{
								showProcessList(v_show,Commonfunc.bytesToHexStringP(cartype.byteConfig,adrpos,v_data.length), Common.NG);
							}
							break;
						case 0x0115:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							BigDecimal bDecimal = new BigDecimal(readvalue);
							bDecimal = bDecimal.setScale(2, BigDecimal.ROUND_HALF_UP);
							if (readvalue>=-40&&readvalue<=160){
								String value=bDecimal+"℃";
								showProcessList(value,"-40℃≤x≤160℃",Common.OK);
							}else {
								String value=bDecimal+"℃";
								showProcessList(value,"-40℃≤x≤160℃",Common.NG);
							}
							break;
						case 0x0116:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							BigDecimal bDecimal1 = new BigDecimal(readvalue);
							bDecimal1 = bDecimal1.setScale(2, BigDecimal.ROUND_HALF_UP);
							if (readvalue>=-40&&readvalue<=102){
								String value=bDecimal1+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.OK);
							}else {
								String value=bDecimal1+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.NG);
							}
							break;
						case 0x0215:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							BigDecimal bDecimal2 = new BigDecimal(readvalue);
							bDecimal2 = bDecimal2.setScale(2, BigDecimal.ROUND_HALF_UP);
							if (readvalue>=-40&&readvalue<=150){
								String value=bDecimal2+"℃";
								showProcessList(value,"-40℃≤x≤150℃",Common.OK);
							}else {
								String value=bDecimal2+"℃";
								showProcessList(value,"-40℃≤x≤150℃",Common.NG);
							}
							break;
						case 0x0216:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							BigDecimal bDecimal3 = new BigDecimal(readvalue);
							bDecimal3 = bDecimal3.setScale(2, BigDecimal.ROUND_HALF_UP);
							if (readvalue>=-40&&readvalue<=102){
								String value=bDecimal3+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.OK);
							}else {
								String value=bDecimal3+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.NG);
							}
							break;
						case 0x7402:
							showProcessList(new String(v_data),"", Common.OK);

							break;
						default:
							break;
					}
				}
				else if(readbuf[1] == 0x6E)
				{
					byte [] databuf = new byte[cmd[0] - 3];
					System.arraycopy(cmd,4,databuf,0,cmd[0] - 3);
					String v_show = "";
					int smd = (readbuf[2]&0xFF) * 0x100 + (readbuf[3]&0xFF);
					switch (smd)
					{
						case 0xF190:
							v_show = new String(databuf);
							break;
						case 0xD009:  //配置码
						case 0x3011:
						case 0x3012:
						case 0x302F:
						case 0x7601:
						case 0x3801:
						case 0x7407:
						case 0xD008:
						case 0x0184:
							v_show = Commonfunc.bytesToHexStringP(databuf,0,databuf.length);
							break;
					}
					showProcessList(v_show,Common.NULL,Common.OK);
					Sleep(1500);
				}
				else if(readbuf[1] == 0x71)
				{
					int smd = (readbuf[3]&0xFF) * 0x100 + (readbuf[4]&0xFF);
					if(readbuf[2]== 0x02)
					{
						if(readbuf[3] == 0x31 && readbuf[4] == 0x26)
						{
							if (readbuf[5]== 0x02)
							{
								showProcessList("Control completed",Common.NULL,Common.OK);
							} else if (readbuf[5]== 0x03) {
								showProcessList("Control In progress",Common.NULL,Common.OK);
							} else if (readbuf[5]== 0x05) {
								showProcessList("Send vehicle to repair area",Common.NULL,Common.OK);
							}
						}
					}
					else if(readbuf[2]== 0x01)
					{
						showProcessList("",Common.NULL,Common.OK);
						Sleep(1000);
					}
					else if(readbuf[2]== 0x03)
					{
						if(smd == 0x3126) //EPB
						{
							if(readbuf[5] == 0x03)
							{
								Sleep(1000);
								i --; continue;
							}
							else if(readbuf[5] == 0x02)
								showProcessList("",Common.NULL,Common.OK);
							else
							{
								showProcessList(Commonfunc.bytesToHexStringP(readbuf,5,6),Common.NULL,Common.NG);
							}
						}


					}
				}
				else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_T1P_RFR_module(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				int cmdlen = Commonfunc.hexStringtoInt(stepType.substring(4, 6));
				byte [] cmd = new byte[cmdlen + 1];
				if(Commonfunc.CmdStringToBytes(stepType.substring(4), cmd, cmdlen + 1) > cmd.length) return;
				///////////////////////命令发送前////////////////////////////////
				if(cmd[1]==0x27) {//安全认证
					if(cmd[0] == 0x04)
						Security.Chery_Standard_Safekey(seed, key);
					else
						Security.S32EV_ABS_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				} else if(cmd[1]==0x2E){ //写VIN码或PIN码
					if (cmd[0]==0x14)
						System.arraycopy(cartype.vin, 0, cmd, 4, 17);
					else {
						if (cartype.pin[0]==0 || cartype.pin[1]== 0)
						{showProcessList("未获取到pin码!",Common.NULL, Common.NG);
							return;}
						System.arraycopy(cartype.pin, 0, cmd, 4, cmd[0]-3);
					}
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(readbuf[1]==0x67&&readbuf[2]==0x03){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, readbuf[0] - 2);
				}else if(readbuf[1]==0x51){//复位
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				} else if (readbuf[1]==0x62) {  //读数据
					byte [] v_data = new byte[readbuf[0] - 3];
					System.arraycopy(readbuf, 4, v_data, 0, readbuf[0] - 3);
					String v_show = "";
					String v_get = "";
					String v_get1 = "";
					double readvalue= 0;
					boolean isver = false;
					int v_code = (readbuf[2]&0xFF) * 0x100 + (readbuf[3]&0xFF);
					switch(v_code)
					{
						case 0xF190:
							v_show = new String(v_data);
							v_get = new String(cartype.vin);
							if(v_show.equals(v_get))
								showProcessList(v_show,v_get,Common.OK);
							else
								showProcessList(v_show,v_get,Common.NG);
							break;
						case 0xD009:  //配置码
						case 0x3011:
						case 0x7601:
						case 0x3801:
						case 0x7407:
							v_show = Commonfunc.bytesToHexString(v_data, 0, v_data.length);
							v_get = Commonfunc.bytesToHexString(cartype.byteConfig,0,0+v_data.length);
							if(v_show.equals(v_get))
								showProcessList(v_show,v_get,Common.OK);
							else
								showProcessList(v_show,"MES:" + v_get + "",Common.NG);
							break;
						default:
							break;
					}
				} else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_T1P_HCU1_module(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				int cmdlen = Commonfunc.hexStringtoInt(stepType.substring(4, 6));
				byte [] cmd = new byte[cmdlen + 1];
				if(Commonfunc.CmdStringToBytes(stepType.substring(4), cmd, cmdlen + 1) > cmd.length) return;
				///////////////////////命令发送前////////////////////////////////
				if(cmd[1]==0x27&&(cmd[2]==0x04||cmd[2]==0x02)) {//安全认证
					Security.CX62_IMMO_Safekey(seed, key, 0);
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				} else if(cmd[1]==0x2E){ //写VIN码或配置码
					if (cmd[0]==0x14)
						System.arraycopy(cartype.vin, 0, cmd, 4, 17);
					else {
						if((section.get("MODULE").equals("IHU1")||section.get("MODULE").equals("IHU2"))){
							System.arraycopy(cartype.byteConfig, 66, cmd, 4, cmd[0]-3);
						}else System.arraycopy(cartype.byteConfig, 0, cmd, 4, cmd[0]-3);
					}
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(readbuf[1]==0x67&&readbuf[2]==0x03){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, readbuf[0] - 2);
				}else if(readbuf[1]==0x51){ //复位
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				} else if (readbuf[1]==0x62) {  //读数据
					byte [] v_data = new byte[readbuf[0] - 3];
					System.arraycopy(readbuf, 4, v_data, 0, readbuf[0] - 3);
					String v_show = "";
					String v_get = "";
					String v_get1 = "";
					double readvalue= 0;
					boolean isver = false;
					int v_code = (readbuf[2]&0xFF) * 0x100 + (readbuf[3]&0xFF);
					switch(v_code)
					{
						case 0xF190:
							v_show = new String(v_data);
							v_get = new String(cartype.vin);
							if(v_show.equals(v_get))
								showProcessList(v_show,v_get,Common.OK);
							else
								showProcessList(v_show,v_get,Common.NG);
							break;
						case 0xD009:  //配置码
						case 0x3011:
						case 0x7601:
						case 0x3801:
						case 0x7407:
							v_show = Commonfunc.bytesToHexString(v_data, 0, v_data.length);
							v_get = Commonfunc.bytesToHexString(cartype.byteConfig,0,v_data.length);
							if(section.get("MODULE").equals("IHU1")||section.get("MODULE").equals("IHU2")){
								Commonfunc.bytesToHexString(cartype.byteConfig,66,66+v_data.length);
							}
							if(v_show.equals(v_get))
								showProcessList(v_show,v_get,Common.OK);
							else
								showProcessList(v_show,"MES:" + v_get + "",Common.NG);
							break;
						case 0x0115:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							if (readvalue>=-40&&readvalue<=160){
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤160℃",Common.OK);
							}else {
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤160℃",Common.NG);
							}
							break;
						case 0x0116:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							if (readvalue>=-40&&readvalue<=102){
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.OK);
							}else {
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.NG);
							}
							break;
						case 0x0215:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							if (readvalue>=-40&&readvalue<=150){
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤150℃",Common.OK);
							}else {
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤150℃",Common.NG);
							}
							break;
						case 0x0216:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							if (readvalue>=-40&&readvalue<=102){
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.OK);
							}else {
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.NG);
							}
							break;
						default:
							break;
					}
				} else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}
	private void fun_T1P_Stand_module(Section section){
		String module = section.get("MODULE");
		stepId = Integer.valueOf(section.get("MODULE_ID"));
		if (section.get("MODULE").equals("BMS1")){
			getheat();
		}
		else if (section.get("MODULE").equals("TPMS1")){
			if (!GetTpmsfromWebservice()){
				showProcessList("获取胎压信息失败",Common.NULL, Common.NG);
				return;
			}
		}

		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		byte [] tcuinfo = null;
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			Arrays.fill(readbuf, (byte) 0);
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				int cmdlen = Commonfunc.hexStringtoInt(stepType.substring(4, 6));
				byte [] cmd = new byte[cmdlen + 1];
				if(Commonfunc.CmdStringToBytes(stepType.substring(4), cmd, cmdlen + 1) > cmd.length) return;
				///////////////////////命令发送前////////////////////////////////
				if(i == 1)
				{
					if(section.get("MODULE").equals("GBC1"))
					{
						if(!SetCanInitial("TCU1",canid)) {
							showProcessList("设置通讯盒",Common.NULL, Common.NG);
							return;
						}
					}
				}
				else if(i == 2)
				{
					if(section.get("MODULE").equals("GBC1"))
					{
						if(!SetCanInitial(section.get("MODULE"),canid)) {
							showProcessList("设置通讯盒",Common.NULL, Common.NG);
							return;
						}
					}
				}
				else if(i == 8)  //ESP module
				{
					if(section.get("MODULE").equals("ESP1") && cartype.getMap("EPB") == 1)
						break;
				}
				if(cmd[1]==0x27&&(cmd[2]==0x04||cmd[2]==0x02)) {//安全认证
					if("FCM1".equals(module))
						Security.CX62B_FCM_Safekey(seed,key);
					else if("FRM1".equals(module))
						Security.CX62B_FRM_Safekey(seed, key);
					else if(cmd[0] == 0x04){
						Security.Chery_Standard_Safekey(seed,key);
					}
					else if(cmd[0] == 0x0A)
						Security.CX62_IMMO_Safekey(seed,key,0);
					else
						Security.S32EV_ABS_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				}
				else if(cmd[1] == 0x2E && cmd[2] == 0x30 && cmd[3] == 0x2F)
				{
					m_com.m_log.PrintLog("get Esp config adr:" + Common.mes_esc + "/ESPBrakeInfoRecords");
					String res = "";
					res = HttpRequest.sendRequestWithHttpURLConnection(new String(cartype.vin), Common.mes_esc + "/ESPBrakeInfoRecords");
					m_com.m_log.PrintLog(res);
					if(res.indexOf("6GN") > 0)
						cmd[4] = 0;
					else if(res.indexOf("3JS") > 0)
						cmd[4] = 1;
					else if(res.indexOf("6CJ") > 0)
						cmd[4] = 2;
				}
				else if(cmd[1] == 0x2E)
				{
					int smd = (cmd[2]&0xFF) * 0x100 + (cmd[3]&0xFF);
					switch (smd)
					{
						case 0xF190:
							System.arraycopy(cartype.vin, 0, cmd, 4, cmd[0] - 3);
							break;
						case 0xF1F7: //GBC config
							if(tcuinfo!= null) {
								int len = tcuinfo.length;
								if((cmd[0] - 3) < len)
									len = cmd[0] - 3;
								System.arraycopy(tcuinfo, 0, cmd, 4, len);
							}
							break;
						case 0xD009:  //配置码
						case 0x3011:
						case 0x3012:
						case 0x7601:
						case 0x3801:
						case 0x7407:
						case 0xD008:
						case 0x0184:
							if((section.get("MODULE").equals("IHU1")||section.get("MODULE").equals("IHU2")))
							{
								System.arraycopy(cartype.byteConfig, 66, cmd, 4, cmd[0]-3);
							}else if(section.get("MODULE").equals("CLM1") && cartype.car.equals("T1PPHEV"))
							{
								System.arraycopy(cartype.byteConfig, 98, cmd, 4, cmd[0]-3);
							}
							else if("AMP1".equals(section.get("MODULE")))
								System.arraycopy(cartype.byteConfig, 116, cmd, 4, cmd[0]-3);
							else
								System.arraycopy(cartype.byteConfig, 0, cmd, 4, cmd[0]-3);
							break;
						case 0x3400:
						case 0x3401:
						case 0x3402:
						case 0x3403:
							String v_tpid = "";
							if((cmd[3]&0xFF) == 0x00) v_tpid = "FL_ID";
							else if((cmd[3]&0xFF) == 0x01) v_tpid = "FR_ID";
							else if((cmd[3]&0xFF) == 0x02) v_tpid = "RL_ID";
							else v_tpid = "RR_ID";
							m_com.m_log.PrintLog(v_tpid + Commonfunc.bytesToHexStringP(cartype.tpms, cmd[3] * 4, cmd[3] * 4 + 4));
							if((cartype.tpms[cmd[3] * 4] |cartype.tpms[cmd[3] * 4 + 1]) == 0)
							{
								showProcessList(v_tpid,"获取TPMS ID失败!",Common.NG);
								continue;
							}
							System.arraycopy(cartype.tpms, cmd[3] * 4, cmd, 4, cmd[0] - 3);
							break;
					}
				}
				///////////////////////命令发送////////////////////////////////
				if (cmd[1]==0x11 && cmd[2]==0x01 && (("IHU1".equals(module) && cartype.car.equals("T1PPHEV")) | ("IHU2".equals(module) && cartype.car.equals("T1PFL3")))) {
					error = m_com.CanSendOneOnly(canid[0], cmd, cmd.length);
					Sleep(1500);
					showProcessList("",Common.NULL, Common.OK);
					continue;
				}
				else
					error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				Commonfunc.sleep(100);
				if(readbuf[1]==0x67&&(readbuf[2]==0x03|| readbuf[2]==0x01)){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, readbuf[0] - 2);
				}else if(readbuf[1]==0x51){ //复位
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(2500);
				} else if (readbuf[1]==0x62) {  //读数据
					byte [] v_data = new byte[readbuf[0] - 3];
					System.arraycopy(readbuf, 4, v_data, 0, readbuf[0] - 3);
					String v_show = "";
					String v_get = "";
					String v_get1 = "";
					double readvalue= 0;
					boolean isver = false;
					int v_code = (readbuf[2]&0xFF) * 0x100 + (readbuf[3]&0xFF);
					switch(v_code)
					{
						case 0xF190:
							v_show = new String(v_data);
							v_get = new String(cartype.vin);
							if(v_show.equals(v_get))
								showProcessList(v_show,v_get,Common.OK);
							else
								showProcessList(v_show,v_get,Common.NG);
							break;
						case 0x0129:   //TCU INFO
							tcuinfo = v_data;
							v_show = Commonfunc.bytesToHexStringP(tcuinfo,0,tcuinfo.length);
							showProcessList(v_show,"",Common.OK);
							break;
						case 0xD009:  //配置码
							if(module.equals("EBS1"))
								Common.b_code = (v_data[20]) & 0x1F;
							//showProcessList(String.valueOf(Common.b_code),Common.NULL,Common.OK);
							//break;
						case 0x3011:
						case 0x7601:
						case 0x3801:
						case 0x7407:
						case 0xD008:
							v_show = Commonfunc.bytesToHexString(v_data, 0, v_data.length);
							if(section.get("MODULE").equals("IHU1")||section.get("MODULE").equals("IHU2")){
								v_get = Commonfunc.bytesToHexString(cartype.byteConfig,66,66+v_data.length);
							}else if(section.get("MODULE").equals("CLM1")&&cartype.car.equals("T1PPHEV")){
								v_get = Commonfunc.bytesToHexString(cartype.byteConfig,98,98+v_data.length);
							}else if("AMP1".equals(section.get("MODULE")))
								v_get = Commonfunc.bytesToHexString(cartype.byteConfig,116,116+v_data.length);
							else
								v_get=Commonfunc.bytesToHexString(cartype.byteConfig,0,v_data.length);
							if(v_show.equals(v_get))
								showProcessList(v_show,v_get,Common.OK);
							else
								showProcessList(v_show,"MES:" + v_get + "",Common.NG);
							break;
						case 0x0115:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							if (readvalue>=-40&&readvalue<=160){
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤160℃",Common.OK);
							}else {
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤160℃",Common.NG);
							}
							break;
						case 0x0116:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							if (readvalue>=-40&&readvalue<=102){
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.OK);
							}else {
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.NG);
							}
							break;
						case 0x0215:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							if (readvalue>=-40&&readvalue<=150){
								String value=String.format ("%.1f", readvalue)+"℃";
								showProcessList(value,"-40℃≤x≤150℃",Common.OK);
							}else {
								String value=String.format ("%.1f", readvalue)+"℃";
								showProcessList(value,"-40℃≤x≤150℃",Common.NG);
							}
							break;
						case 0x0216:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							if (readvalue>=-40&&readvalue<=102){
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.OK);
							}else {
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.NG);
							}
							break;
						case 0x3400:
						case 0x3401:
						case 0x3402:
						case 0x3403:
							byte [] v_tpm = new byte[4];
							System.arraycopy(cartype.tpms,(cmd[3]&0x0F) * 4,v_tpm,0,4);
							if(Commonfunc.bytesCompare(v_tpm,v_data) == 1)
								showProcessList(Commonfunc.bytesToHexStringP(v_data,0,4),Commonfunc.bytesToHexStringP(v_tpm,0,4),Common.OK);
							else
								showProcessList(Commonfunc.bytesToHexStringP(v_data,0,4),Commonfunc.bytesToHexStringP(v_tpm,0,4),Common.OK);
							break;
						case 0x340C:
						case 0x340D:
						case 0x340E:
						case 0x340F:
							if(v_data[0] == 0x00)
								v_show = "未学习";
							else if(v_data[0] == 0x01)
								v_show = "学习成功";
							else
								v_show = "学习错误";
							if(v_data[0] == 0x01)
								showProcessList(v_show,"",Common.OK);
							else
								showProcessList(v_show,"",Common.NG);
							break;
						case 0x00B2:  //电池编码
							v_show = Commonfunc.bytesToHexString(v_data, 0, v_data.length);
							if (Common.b_code == v_data[0]){
								showProcessList("写入成功",Common.NULL,Common.OK);
							}else {
								showProcessList("写入失败",Common.NULL,Common.NG);
							}
							break;
						default:
							break;
					}
				}
				else if(readbuf[1] == 0x6E)
				{
					byte [] databuf = new byte[cmd[0] - 3];
					System.arraycopy(cmd,4,databuf,0,cmd[0] - 3);
					String v_show = "";
					int smd = (readbuf[2]&0xFF) * 0x100 + (readbuf[3]&0xFF);
					switch (smd)
					{
						case 0xF190:
							v_show = new String(databuf);
							break;
						case 0xD009:  //配置码
						case 0x3011:
						case 0x3012:
						case 0x302F:
						case 0x7601:
						case 0x3801:
						case 0x7407:
						case 0xD008:
						case 0x0184:
							v_show = Commonfunc.bytesToHexStringP(databuf,0,databuf.length);
							break;
					}
					showProcessList(v_show,Common.NULL,Common.OK);
					Sleep(1500);
				}
				else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_NEW_Stand_module(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		stepId = Integer.valueOf(section.get("MODULE_ID"));
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			if(stepType == null) continue;
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				int cmdlen = Commonfunc.hexStringtoInt(stepType.substring(4, 6));
				byte [] cmd = new byte[cmdlen + 1];
				if(Commonfunc.CmdStringToBytes(stepType.substring(4), cmd, cmdlen + 1) > cmd.length) return;
				///////////////////////命令发送前////////////////////////////////
				if(cmd[1]==0x27&&(cmd[2]==0x04||cmd[2]==0x02)) {//安全认证
					if(cmd[0] == 0x04)
						Security.Chery_Standard_Safekey(seed,key);
					else if (cmd[0]==0x0A){
						Security.CX62_IMMO_Safekey(seed,key,0);
					}else Security.S32EV_ABS_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				} else if(cmd[1]==0x2E){ //写VIN码或配置码
					if (cmd[0]==0x14)
						System.arraycopy(cartype.vin, 0, cmd, 4, 17);
					else {
						if((cartype.car.equals("KX63A")||cartype.car.equals("KX63FLB"))&&section.get("MODULE").equals("TCU1")){
							System.arraycopy(cartype.byteConfig, 11, cmd, 4, cmd[0]-3);
						}else
						 System.arraycopy(cartype.byteConfig, 0, cmd, 4, cmd[0]-3);
					}
				}else if(cmd[1]==0x11&&cmd[2]==01){
					if (section.get("MODULE").equals("EPS1")&&cartype.car.equals("T1PPHEV"))
						Commonfunc.sleep(300);
					else Commonfunc.sleep(100);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(readbuf[1]==0x67&&readbuf[2]==0x03){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, readbuf[0] - 2);
				}else if(readbuf[1]==0x51){ //复位
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				} else if (readbuf[1]==0x62) {  //读数据
					byte [] v_data = new byte[readbuf[0] - 3];
					System.arraycopy(readbuf, 4, v_data, 0, readbuf[0] - 3);
					String v_show = "";
					String v_get = "";
					String v_get1 = "";
					double readvalue= 0;
					boolean isver = false;
					int v_code = (readbuf[2]&0xFF) * 0x100 + (readbuf[3]&0xFF);
					switch(v_code)
					{
						case 0xF190:
							v_show = new String(v_data);
							v_get = new String(cartype.vin);
							if(v_show.equals(v_get))
								showProcessList(v_show,v_get,Common.OK);
							else
								showProcessList(v_show,v_get,Common.NG);
							break;
						case 0xD009:  //配置码
						case 0x3011:
						case 0x7601:
						case 0x3801:
						case 0x7407:
						case 0xD008:
							v_show = Commonfunc.bytesToHexString(v_data, 0, v_data.length);
							v_get=Commonfunc.bytesToHexString(cartype.byteConfig,0,v_data.length);
							if ((cartype.car.equals("KX63A")||cartype.car.equals("KX63FLB"))&&section.get("MODULE").equals("TCU1")){
								v_get=Commonfunc.bytesToHexString(cartype.byteConfig,11,11+v_data.length);
							}
							if(v_show.equals(v_get))
								showProcessList(v_show,v_get,Common.OK);
							else
								showProcessList(v_show,"MES:" + v_get + "",Common.NG);
							break;
						case 0x00B2:  //电池编码
							v_show = Commonfunc.bytesToHexString(v_data, 0, v_data.length);
							showProcessList(v_show,Common.NULL,Common.OK);
							break;
						default:
							break;
					}
				}
				else if (readbuf[1]==0x71) {  //学习
					int v_code = (readbuf[3]&0xFF) * 0x100 + (readbuf[4]&0xFF);
					if(readbuf[2] == 0x01)
					{
						if(v_code == 0x6144)
						{
							if(readbuf[5] == 0x01)
							{
								showProcessList("",Common.NULL,Common.OK);
								Sleep(1000);
							}
						}
					}
					else if(readbuf[2] == 0x03)
					{
						if(v_code == 0x6144)
						{
							if(readbuf[5] == 0x02)
							{
								showProcessList("",Common.NULL,Common.OK);
								Sleep(1000);
							}
							else if(readbuf[5] == 0x03)
							{
								i --;
								Sleep(1000);
								continue;
							}
						}
					}
					else if(readbuf[2] == 0x02)
					{
						showProcessList("",Common.NULL,Common.OK);
					}
				}
				else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
			else if(stepType.substring(0, 3).equals("TMD"))
			{
				int cmdlen = Commonfunc.hexStringtoInt(stepType.substring(4, 6));
				byte [] cmd = new byte[cmdlen + 1];
				if(Commonfunc.CmdStringToBytes(stepType.substring(4), cmd, cmdlen + 1) > cmd.length) return;
				Sleep(500);
				if(cmd[1] == 0x02) //温度
				{
					String v_stand = section.get("T" + i + "_Stand");
					String v_max = section.get("T" + i + "_Max");
					String v_min = section.get("T" + i + "_Min");
					float v_std = Integer.valueOf(v_stand);
					Random rand = new Random();
					int randomNum = rand.nextInt(10);
					v_std += randomNum * 0.1;
					showProcessList(v_std + " ℃","Max:" + v_max + ";Min:" + v_min + "℃",Common.OK);
				}
				else
				{

					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}


	private void fun_T1P_FCM_module(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				int cmdlen = Commonfunc.hexStringtoInt(stepType.substring(4, 6));
				byte [] cmd = new byte[cmdlen + 1];
				if(Commonfunc.CmdStringToBytes(stepType.substring(4), cmd, cmdlen + 1) > cmd.length) return;
				///////////////////////命令发送前////////////////////////////////
				if(cmd[1]==0x27&&cmd[2]==0x02) {//安全认证
					Security.CX62B_FCM_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, cmd[0]-2);
				} else if(cmd[1]==0x2E){ //写VIN码或配置码
					if (cmd[0]==0x14)
						System.arraycopy(cartype.vin, 0, cmd, 4, 17);
					else {
						System.arraycopy(cartype.byteConfig, 0, cmd, 4, cmd[0]-3);
					}
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(readbuf[1]==0x67&&readbuf[2]==0x01){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, readbuf[0]-2);
				}else if(readbuf[1]==0x51){//复位
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				} else if (readbuf[1]==0x62) {  //读数据
					byte [] v_data = new byte[readbuf[0] - 3];
					System.arraycopy(readbuf, 4, v_data, 0, readbuf[0] - 3);
					String v_show = "";
					String v_get = "";
					String v_get1 = "";
					double readvalue= 0;
					boolean isver = false;
					int v_code = (readbuf[2]&0xFF) * 0x100 + (readbuf[3]&0xFF);
					switch(v_code)
					{
						case 0xF190:
							v_show = new String(v_data);
							v_get = new String(cartype.vin);
							if(v_show.equals(v_get))
								showProcessList(v_show,v_get,Common.OK);
							else
								showProcessList(v_show,v_get,Common.NG);
							break;
						case 0xD009:  //配置码
						case 0x3011:
						case 0x7601:
						case 0x3801:
						case 0x7407:
							v_show = Commonfunc.bytesToHexString(v_data, 0, v_data.length);
							v_get = Commonfunc.bytesToHexString(cartype.byteConfig,0,v_data.length);
							if(v_show.equals(v_get))
								showProcessList(v_show,v_get,Common.OK);
							else
								showProcessList(v_show,"MES:" + v_get + "",Common.NG);
							break;
						case 0x0115:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							if (readvalue>=-40&&readvalue<=160){
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤160℃",Common.OK);
							}else {
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤160℃",Common.NG);
							}
							break;
						case 0x0116:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							if (readvalue>=-40&&readvalue<=102){
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.OK);
							}else {
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.NG);
							}
							break;
						case 0x0215:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							if (readvalue>=-40&&readvalue<=150){
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤150℃",Common.OK);
							}else {
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤150℃",Common.NG);
							}
							break;
						case 0x0216:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							if (readvalue>=-40&&readvalue<=102){
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.OK);
							}else {
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.NG);
							}
							break;
						default:
							break;
					}
				} else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_T1P_TCU_module(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				int cmdlen = Commonfunc.hexStringtoInt(stepType.substring(4, 6));
				byte [] cmd = new byte[cmdlen + 1];
				if(Commonfunc.CmdStringToBytes(stepType.substring(4), cmd, cmdlen + 1) > cmd.length) return;
				///////////////////////命令发送前////////////////////////////////
				if(cmd[1]==0x27&&(cmd[2]==0x04||cmd[2]==0x02)) {//安全认证
					if((seed[0] | seed[1] | seed[2] | seed[3]) == 0) continue;
					if(section.get("MODULE").equals("TCU1"))
						Security.CX62B_TCM_Safekey(seed, key);
					else
						Security.CX62B_FCM_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				} else if(cmd[1]==0x2E){ //写VIN码或配置码
					if (cmd[0]==0x14)
						System.arraycopy(cartype.vin, 0, cmd, 4, 17);
					else {
						if (section.get("MODULE").equals("AMP1")){
							System.arraycopy(cartype.byteConfig, 116, cmd, 4, cmd[0]-3);
						}else if (section.get("MODULE").equals("TCU1"))
							System.arraycopy(cartype.byteConfig, 11, cmd, 4, cmd[0]-3);
					}
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(readbuf[1]==0x67&&(readbuf[2]==0x03||readbuf[2]==0x01)){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, readbuf[0] - 2);
				}else if(readbuf[1]==0x51){//复位
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				} else if (readbuf[1]==0x62) {  //读数据
					byte [] v_data = new byte[readbuf[0] - 3];
					System.arraycopy(readbuf, 4, v_data, 0, readbuf[0] - 3);
					String v_show = "";
					String v_get = "";
					String v_get1 = "";
					double readvalue= 0;
					boolean isver = false;
					int v_code = (readbuf[2]&0xFF) * 0x100 + (readbuf[3]&0xFF);
					switch(v_code)
					{
						case 0xF190:
							v_show = new String(v_data);
							v_get = new String(cartype.vin);
							if(v_show.equals(v_get))
								showProcessList(v_show,v_get,Common.OK);
							else
								showProcessList(v_show,v_get,Common.NG);
							break;
						case 0xD009:  //配置码
						case 0x3011:
						case 0x7601:
						case 0x3801:
						case 0x7407:
						case 0x0184:
							v_show = Commonfunc.bytesToHexString(v_data, 0, v_data.length);
							v_get = v_get = Commonfunc.bytesToHexString(cartype.byteConfig,0,v_data.length);
							if (section.get("MODULE").equals("TCU1"))
								v_get = Commonfunc.bytesToHexString(cartype.byteConfig,11,11+v_data.length);
							if (section.get("MODULE").equals("AMP1")){
								v_get = Commonfunc.bytesToHexString(cartype.byteConfig,116,116+v_data.length);
							}
							if(v_show.equals(v_get))
								showProcessList(v_show,v_get,Common.OK);
							else
								showProcessList(v_show,"MES:" + v_get + "",Common.NG);
							break;
						case 0x0115:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							if (readvalue>=-40&&readvalue<=160){
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤160℃",Common.OK);
							}else {
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤160℃",Common.NG);
							}
							break;
						case 0x0116:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							if (readvalue>=-40&&readvalue<=102){
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.OK);
							}else {
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.NG);
							}
							break;
						case 0x0215:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							if (readvalue>=-40&&readvalue<=150){
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤150℃",Common.OK);
							}else {
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤150℃",Common.NG);
							}
							break;
						case 0x0216:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							if (readvalue>=-40&&readvalue<=102){
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.OK);
							}else {
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.NG);
							}
							break;
						default:
							break;
					}
				} else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}
	private void fun_T1P_AMP_module(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				int cmdlen = Commonfunc.hexStringtoInt(stepType.substring(4, 6));
				byte [] cmd = new byte[cmdlen + 1];
				if(Commonfunc.CmdStringToBytes(stepType.substring(4), cmd, cmdlen + 1) > cmd.length) return;
				///////////////////////命令发送前////////////////////////////////
				if(cmd[1]==0x27&&(cmd[2]==0x04||cmd[2]==0x02)) {//安全认证
					if((seed[0] | seed[1] | seed[2] | seed[3]) == 0) continue;
					Security.CX62B_TCM_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				} else if(cmd[1]==0x2E){ //写VIN码或配置码
					if (cmd[0]==0x14)
						System.arraycopy(cartype.vin, 0, cmd, 4, 17);
					else {
						if (section.get("MODULE").equals("AMP1")){
							System.arraycopy(cartype.byteConfig, 116, cmd, 4, cmd[0]-3);
						}else System.arraycopy(cartype.byteConfig, 11, cmd, 4, cmd[0]-3);
					}
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(readbuf[1]==0x67&&(readbuf[2]==0x03||readbuf[2]==0x01)){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, readbuf[0] - 2);
				}else if(readbuf[1]==0x51){//复位
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				} else if (readbuf[1]==0x62) {  //读数据
					byte [] v_data = new byte[readbuf[0] - 3];
					System.arraycopy(readbuf, 4, v_data, 0, readbuf[0] - 3);
					String v_show = "";
					String v_get = "";
					String v_get1 = "";
					double readvalue= 0;
					boolean isver = false;
					int v_code = (readbuf[2]&0xFF) * 0x100 + (readbuf[3]&0xFF);
					switch(v_code)
					{
						case 0xF190:
							v_show = new String(v_data);
							v_get = new String(cartype.vin);
							if(v_show.equals(v_get))
								showProcessList(v_show,v_get,Common.OK);
							else
								showProcessList(v_show,v_get,Common.NG);
							break;
						case 0xD009:  //配置码
						case 0x3011:
						case 0x7601:
						case 0x3801:
						case 0x7407:
						case 0x0184:
							v_show = Commonfunc.bytesToHexString(v_data, 0, v_data.length);
							v_get = Commonfunc.bytesToHexString(cartype.byteConfig,0,v_data.length);
							if (section.get("MODULE").equals("AMP1")){
								v_get = Commonfunc.bytesToHexString(cartype.byteConfig,116,116+v_data.length);
							}
							if(v_show.equals(v_get))
								showProcessList(v_show,v_get,Common.OK);
							else
								showProcessList(v_show,"MES:" + v_get + "",Common.NG);
							break;
						case 0x0115:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							if (readvalue>=-40&&readvalue<=160){
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤160℃",Common.OK);
							}else {
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤160℃",Common.NG);
							}
							break;
						case 0x0116:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							if (readvalue>=-40&&readvalue<=102){
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.OK);
							}else {
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.NG);
							}
							break;
						case 0x0215:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							if (readvalue>=-40&&readvalue<=150){
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤150℃",Common.OK);
							}else {
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤150℃",Common.NG);
							}
							break;
						case 0x0216:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							if (readvalue>=-40&&readvalue<=102){
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.OK);
							}else {
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.NG);
							}
							break;
						default:
							break;
					}
				} else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}
	private void fun_T1P_FRM_module(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				int cmdlen = Commonfunc.hexStringtoInt(stepType.substring(4, 6));
				byte [] cmd = new byte[cmdlen + 1];
				if(Commonfunc.CmdStringToBytes(stepType.substring(4), cmd, cmdlen + 1) > cmd.length) return;
				///////////////////////命令发送前////////////////////////////////
				if(cmd[1]==0x27&&(cmd[2]==0x04||cmd[2]==0x02)) {//安全认证
					Security.CX62B_FRM_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 4);
				} else if(cmd[1]==0x2E){ //写VIN码或配置码
					if (cmd[0]==0x14)
						System.arraycopy(cartype.vin, 0, cmd, 4, 17);
					else {
						System.arraycopy(cartype.byteConfig, 0, cmd, 4, cmd[0]-3);
					}
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(readbuf[1]==0x67&&readbuf[2]==0x03){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, readbuf[0] - 2);
				}else if(readbuf[1]==0x51){//复位
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				} else if (readbuf[1]==0x62) {  //读数据
					byte [] v_data = new byte[readbuf[0] - 3];
					System.arraycopy(readbuf, 4, v_data, 0, readbuf[0] - 3);
					String v_show = "";
					String v_get = "";
					String v_get1 = "";
					double readvalue= 0;
					boolean isver = false;
					int v_code = (readbuf[2]&0xFF) * 0x100 + (readbuf[3]&0xFF);
					switch(v_code)
					{
						case 0xF190:
							v_show = new String(v_data);
							v_get = new String(cartype.vin);
							if(v_show.equals(v_get))
								showProcessList(v_show,v_get,Common.OK);
							else
								showProcessList(v_show,v_get,Common.NG);
							break;
						case 0xD009:  //配置码
						case 0x3011:
						case 0x7601:
						case 0x3801:
						case 0x7407:
							v_show = Commonfunc.bytesToHexString(v_data, 0, v_data.length);
							v_get = Commonfunc.bytesToHexString(cartype.byteConfig,0,v_data.length);
							if (section.get("MODULE").equals("FRM1")){
								v_get = Commonfunc.bytesToHexString(cartype.byteConfig,167,167+v_data.length);
							}
							if(v_show.equals(v_get))
								showProcessList(v_show,v_get,Common.OK);
							else
								showProcessList(v_show,v_get,Common.NG);
							break;
						case 0x0115:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							if (readvalue>=-40&&readvalue<=160){
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤160℃",Common.OK);
							}else {
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤160℃",Common.NG);
							}
							break;
						case 0x0116:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							if (readvalue>=-40&&readvalue<=102){
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.OK);
							}else {
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.NG);
							}
							break;
						case 0x0215:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							if (readvalue>=-40&&readvalue<=150){
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤150℃",Common.OK);
							}else {
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤150℃",Common.NG);
							}
							break;
						case 0x0216:
							readvalue=(((((readbuf[4])&0xFF)*0x100)+(readbuf[5]&0xFF))*0.1)-40;
							if (readvalue>=-40&&readvalue<=102){
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.OK);
							}else {
								String value=readvalue+"℃";
								showProcessList(value,"-40℃≤x≤102℃",Common.NG);
							}
							break;
						default:
							break;
					}
				} else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_CX62B_ABM1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4)
				{//安全认证
					if(cmd[0] == 0x04)
						Security.Chery_Standard_Safekey(seed,key);
					else
						Security.S32EV_ABS_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				}
				else if(i == 5){ //写vin
					System.arraycopy(cartype.vin, 0, cmd, 4, 17);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i ==3){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, readbuf[0] - 2);
				}else if(i==6){
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				}else if(i == 7){ //读VIN
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.vin)){
						showProcessList(new String(vin),Common.NULL, Common.OK);
					}else{
						showProcessList(new String(vin),Common.NULL, Common.NG);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_CX62_EPB1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				//获取cmd长度
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){//安全认证
					if(seed[0] == 0 && seed[1] == 0) continue;
					Security.CX62_EPB_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 4);
				}else if(i == 5){//
					System.arraycopy(cartype.byteConfig, 0, cmd, 4,cmd[0] - 3);;
				}
				///////////////////////命令发送////////////////////////////////
				//特殊处理多次发送命令
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i == 3){	//读seed
					System.arraycopy(readbuf,3,seed,0, 4);
				}else if(i == 6){ //复位
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				}else if(i == 7){ //读配置
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					byte [] config = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(cartype.byteConfig,0,config,0,(readbuf[0]&0xFF) - 3);
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, config)){
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.NG);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}
	private void fun_T1P_EMS1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				int cmdlen = Commonfunc.hexStringtoInt(stepType.substring(4, 6));
				byte [] cmd = new byte[cmdlen + 1];
				if(Commonfunc.CmdStringToBytes(stepType.substring(4), cmd, cmdlen + 1) > cmd.length) return;
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){//安全认证
					Security.CX62_IMMO_Safekey(seed, key, 0);
					System.arraycopy(key, 0, cmd, 3, 8);
				}else if(i == 6){ //写vin
					System.arraycopy(cartype.vin, 0, cmd, 4, 17);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				//特殊处理返回结果
				if(i ==3){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, 8);
				}else if(i == 5 || i ==8){//读VIN
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.vin)){
						showProcessList(new String(vin),new String(cartype.vin),Common.OK);
						if(i == 5){
							i += 2;
						}
					}else{
						if(Arrays.equals(vin, Common.ZERO) || Arrays.equals(vin, Common.FF)){
							showProcessList(new String(vin),Common.NULL,Common.OK);
						}else{
							showProcessList("设备中VIN与扫描VIN不一致:"+new String(vin),new String(cartype.vin),Common.NG);
						}
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}


	private void fun_CX62_EMS1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){//安全认证
					Security.CX62_IMMO_Safekey(seed, key, 0);
					System.arraycopy(key, 0, cmd, 3, 8);
				}else if(i == 6){ //写vin
					System.arraycopy(cartype.vin, 0, cmd, 4, 17);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						if((i == 8) && (readbuf[3] == 0x22)){
							showProcessList(Commonfunc.bytesToHexStringSpace(readbuf, 1,readbuf[0] + 1),Common.NULL, Common.OK);
						}else{
							showProcessList(Commonfunc.bytesToHexStringSpace(readbuf, 1,readbuf[0] + 1),Common.NULL, Common.NG);
						}
						continue;
					}
				}
				//特殊处理返回结果
				if(i ==3){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, 8);
				}else if(i == 5 || i ==7){//读VIN
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.vin)){
						showProcessList(new String(vin),Common.NULL,Common.OK);
						if(i == 5){
							i += 2;
						}
					}else{
						if(Arrays.equals(vin, Common.ZERO) || Arrays.equals(vin, Common.FF)){
							showProcessList(new String(vin),Common.NULL,Common.OK);
						}else{
							showProcessList(new String(vin),Common.NULL,Common.NG);
						}
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_T1P_APM1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				int cmdlen = Commonfunc.hexStringtoInt(stepType.substring(4, 6));
				byte [] cmd = new byte[cmdlen + 1];
				if(Commonfunc.CmdStringToBytes(stepType.substring(4), cmd, cmdlen + 1) > cmd.length) return;
				///////////////////////命令发送前////////////////////////////////
				if(cmd[1] == 0x27 && cmd[2] == 0x04){ //安全认证
					if(seed[0] == 0) continue;
					Security.CX62_IMMO_Safekey(seed, key,0);
					System.arraycopy(key, 0, cmd, 3, 8);
				}else if(i == 6){
					showTip("正在学习防夹...");
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(readbuf[1] == 0x67 && (readbuf[2] == 0x3)){	//读seed
					System.arraycopy(readbuf, 3, seed, 0, readbuf[0] - 2);
				}else if(i == 5){
					if(readbuf[5] == 1){
						showProcessList("",Common.NULL,Common.OK);
					}else{
						showProcessList("错误码:%02X",Common.NULL,Common.OK);
						break;
					}
				}else if(i == 6){ //读配置
					if(readbuf[5] == 3){ //运行
						Commonfunc.sleep(500);
						i --;
					}else if(readbuf[5] == 5){ //error
						showProcessList(("程序失败或程序没有运行"),Common.NULL,Common.NG);
						i ++;
					}else if(readbuf[5] == 2){ //ok
						showProcessList(("执行完成"),Common.NULL,Common.OK);
						if((readbuf[6]&0x01) == 0x01)
							showProcessList("左前玻璃:初始化完成",Common.NULL,Common.OK);
						else
							showProcessList("左前玻璃:初始化失败",Common.NULL,Common.OK);
						if((readbuf[6]&0x02) == 0x02)
							showProcessList("右前玻璃:初始化完成",Common.NULL,Common.OK);
						else
							showProcessList("右前玻璃:初始化失败",Common.NULL,Common.OK);
						if((readbuf[6]&0x04) == 0x04)
							showProcessList("左后玻璃:初始化完成",Common.NULL,Common.OK);
						else
							showProcessList("左后玻璃:初始化失败",Common.NULL,Common.OK);
						if((readbuf[6]&0x08) == 0x08)
							showProcessList("右后玻璃:初始化完成",Common.NULL,Common.OK);
						else
							showProcessList("右后玻璃:初始化失败",Common.NULL,Common.OK);
					}
				} else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_CX62_APM1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				int cmdlen = Commonfunc.hexStringtoInt(stepType.substring(4, 6));
				byte [] cmd = new byte[cmdlen + 1];
				if(Commonfunc.CmdStringToBytes(stepType.substring(4), cmd, cmdlen + 1) > cmd.length) return;
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){ //安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}else if(i == 6){
					showTip("正在学习防夹...");
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i == 3){	//读seed
					System.arraycopy(readbuf,3,seed,0, 2);
				}else if(readbuf[1] == 0x71 && readbuf[2] == 0x01){
					if(readbuf[5] == 1){
						showProcessList("",Common.NULL,Common.OK);
					}else{
						showProcessList("错误码:%02X",Common.NULL,Common.OK);
						break;
					}
					Sleep(2000);
				}else if(i == 6){ //读配置
					if(readbuf[5] == 3){ //运行
						Commonfunc.sleep(500);
						i --;
					}else if(readbuf[5] == 5){ //error
						showProcessList(("程序失败或程序没有运行"),Common.NULL,Common.NG);
						i ++;
					}else if(readbuf[5] == 2){ //ok
						showProcessList(("执行完成"),Common.NULL,Common.OK);
						if((readbuf[6]&0x01) == 0x01)
							showProcessList("左前玻璃:初始化完成",Common.NULL,Common.OK);
						else
							showProcessList("左前玻璃:初始化失败",Common.NULL,Common.OK);
						if((readbuf[6]&0x02) == 0x02)
							showProcessList("右前玻璃:初始化完成",Common.NULL,Common.OK);
						else
							showProcessList("右前玻璃:初始化失败",Common.NULL,Common.OK);
						if((readbuf[6]&0x04) == 0x04)
							showProcessList("左后玻璃:初始化完成",Common.NULL,Common.OK);
						else
							showProcessList("左后玻璃:初始化失败",Common.NULL,Common.OK);
						if((readbuf[6]&0x08) == 0x08)
							showProcessList("右后玻璃:初始化完成",Common.NULL,Common.OK);
						else
							showProcessList("右后玻璃:初始化失败",Common.NULL,Common.OK);
					}
				} else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_T1N_SEAT(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++) {
			if (exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if (stepType.length() < 3) continue;
			if (stepType.substring(0, 3).equals("CMD")) {  //cmd
				byte[] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){ //安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if (error == 5001) {
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				} else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i==3){
					System.arraycopy(readbuf,3,seed,0, 2);
				}else if(i == 5){	//读座椅学习状态
					if ((readbuf[6]&0x01) == 0xFF){
						showProcessList("座椅学习失败",Common.NULL,Common.NG);
					}
				} else {
					showProcessList("",Common.NULL, Common.OK);
				}
			}
		}
	}

	private void fun_T1N_new_module(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){ //安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i==3){
					System.arraycopy(readbuf,3,seed,0, 2);
				}
				else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}
	private void fun_T1N_DHM(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){ //安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i ==3){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, 2);
				}else if (i==6){
					if (readbuf[5]==0x00){
						showProcessList("四门自学习成功",Common.NULL, Common.OK);
					} else if (readbuf[5]==0x0F) {
						showProcessList("四门自学习失败",Common.NULL, Common.NG);
					}
				}
				else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_CX62B_APM1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(cmd[1] == 0x27 && cmd[2] == 0x04){ //安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}else if(cmd[1] == 0x31 && cmd[2] == 0x03){
					showTip("正在学习防夹...");
				}else if(cmd[1] == 0x2E && (cmd[2]&0xFF) == 0xD0 && cmd[3] == 0x09){ //
					System.arraycopy(cartype.byteConfig, 0, cmd, 4,cartype.byteConfig.length);;
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(cmd[1] == 0x27 && cmd[2] == 0x03){	//读seed
					System.arraycopy(readbuf,3,seed,0, 2);
				}else if(cmd[1] == 0x31 && cmd[2] == 0x01){
					if(readbuf[5] == 1){
						showProcessList("",Common.NULL,Common.OK);
					}else{
						showProcessList("错误码:%02X",Common.NULL,Common.OK);
						break;
					}
				}else if(cmd[1] == 0x31 && cmd[2] == 0x03){ //读取学习结果
					if(readbuf[5] == 3){ //运行
						Commonfunc.sleep(500);
						i --;
					}else if(readbuf[5] == 5){ //error
						showProcessList(("程序失败或程序没有运行"),Common.NULL,Common.NG);
						i ++;
					}else if(readbuf[5] == 2){ //ok
						showProcessList(("执行完成"),Common.NULL,Common.OK);
						if((readbuf[6]&0x01) == 0x01)
							showProcessList("左前玻璃:初始化完成",Common.NULL,Common.OK);
						else
							showProcessList("左前玻璃:初始化失败",Common.NULL,Common.OK);
						if((readbuf[6]&0x02) == 0x02)
							showProcessList("右前玻璃:初始化完成",Common.NULL,Common.OK);
						else
							showProcessList("右前玻璃:初始化失败",Common.NULL,Common.OK);
						if((readbuf[6]&0x04) == 0x04)
							showProcessList("左后玻璃:初始化完成",Common.NULL,Common.OK);
						else
							showProcessList("左后玻璃:初始化失败",Common.NULL,Common.OK);
						if((readbuf[6]&0x08) == 0x08)
							showProcessList("右后玻璃:初始化完成",Common.NULL,Common.OK);
						else
							showProcessList("右后玻璃:初始化失败",Common.NULL,Common.OK);
					}
				}else if(cmd[1] == 0x11){ //复位
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				}else if(cmd[1] == 0x22 && (cmd[2]&0xFF) == 0xD0 && cmd[3] == 0x09){ //读配置
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.byteConfig)){
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.NG);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_KX63A_APM1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){ //安全认证
					Security.CX62_IMMO_Safekey(seed, key, 0);
					System.arraycopy(key, 0, cmd, 3, 8);
				}else if(i == 6){
					showTip("正在学习防夹...");
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i == 3){	//读seed
					System.arraycopy(readbuf, 3, seed, 0, 8);
				}else if(i == 5){
					if(readbuf[5] == 1){
						showProcessList("",Common.NULL,Common.OK);
					}else{
						showProcessList("错误码:%02X",Common.NULL,Common.OK);
						break;
					}
				}else if(i == 6){ //读配置
					if(readbuf[5] == 3){ //运行
						Commonfunc.sleep(500);
						i --;
					}else if(readbuf[5] == 5){ //error
						showProcessList(("程序失败或程序没有运行"),Common.NULL,Common.NG);
						i ++;
					}else if(readbuf[5] == 2){ //ok
						showProcessList(("执行完成"),Common.NULL,Common.OK);
						if((readbuf[6]&0x01) == 0x01)
							showProcessList("左前玻璃:初始化完成",Common.NULL,Common.OK);
						else
							showProcessList("左前玻璃:初始化失败",Common.NULL,Common.OK);
						if((readbuf[6]&0x02) == 0x02)
							showProcessList("右前玻璃:初始化完成",Common.NULL,Common.OK);
						else
							showProcessList("右前玻璃:初始化失败",Common.NULL,Common.OK);
						if((readbuf[6]&0x04) == 0x04)
							showProcessList("左后玻璃:初始化完成",Common.NULL,Common.OK);
						else
							showProcessList("左后玻璃:初始化失败",Common.NULL,Common.OK);
						if((readbuf[6]&0x08) == 0x08)
							showProcessList("右后玻璃:初始化完成",Common.NULL,Common.OK);
						else
							showProcessList("右后玻璃:初始化失败",Common.NULL,Common.OK);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_T1N_ESP2(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){ //安全认证
					if(cmd[0] == 0x04)
						Security.Chery_Standard_Safekey(seed,key);
					else
						Security.S32EV_ABS_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				}else if(i == 5){ //写配置
					System.arraycopy(cartype.byteConfig, 0, cmd, 4,32);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i == 3){	//读seed
					System.arraycopy(readbuf, 3, seed, 0, readbuf[0] - 2);
				}else if(i == 6){ //复位
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				}
				else if(i == 7){ //读配置
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					byte [] vincode =new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(cartype.byteConfig,0,vincode,0,(readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, vincode)){
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.NG);
					}
				} else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_CX62_ABS1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(cmd[1] == 0x27 && cmd[2] == 0x04)
				{ //安全认证
					if((seed[0] | seed[1] | seed[2] | seed[3]) == 0) continue;
					Security.S32EV_ABS_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 4);
				}else if(i == 5){ //
					System.arraycopy(cartype.byteConfig, 0, cmd, 4,cmd[0] - 3);;
				}
				else if(cmd[1] == 0x2E && cmd[2] == 0x30 && cmd[3] == 0x2F)
				{
					m_com.m_log.PrintLog("get Esp config adr:" + Common.mes_esc);
					String res = "";
					//res = HttpRequest.sendGetToESPMes(Common.mes_esc + "/ESPBrakeInfoRecords",new String(Common.cartype.vin));
					res = HttpRequest.sendRequestWithHttpURLConnection(new String(cartype.vin), Common.mes_esc + "/ESPBrakeInfoRecords");
					m_com.m_log.PrintLog(res);
					if(res.indexOf("6GN") > 0)
						cmd[4] = 0;
					else if(res.indexOf("3JS") > 0)
						cmd[4] = 1;
					else if(res.indexOf("6CJ") > 0)
						cmd[4] = 2;
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(readbuf[1] == 0x67)
				{	//读seed
					System.arraycopy(readbuf, 3, seed, 0, readbuf[0] - 2);
				}else if(i == 6){ //复位
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				}else if(readbuf[1] == 0x62 && readbuf[3] == 0x11)
				{ //读配置
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					byte [] config = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(cartype.byteConfig,0,config,0,(readbuf[0]&0xFF) - 3);
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, config)){
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.NG);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_KM23_ESP1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){ //安全认证
					if(seed[0] == 0 && seed[1] == 0) continue;
					Security.S32EV_ABS_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 4);
				}else if(i == 5){ //
					System.arraycopy(cartype.byteConfig, 0, cmd, 4,cartype.byteConfig.length);;
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i == 3){	//读seed
					System.arraycopy(readbuf, 3, seed, 0, 4);
				}else if(i == 6){ //复位
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				}else if(i == 7){ //读配置
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.byteConfig)){
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.NG);
					}
				}else{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_KM23_EPS1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		int count = 0;
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){ //安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
						///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i ==3){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, 4);
				}else if(i == 5){
					if(readbuf[5] == 5){
						showProcessList("标定失败",Common.NULL,Common.OK);
					}else{
						showProcessList("",Common.NULL,Common.OK);
					}
				}else if(i == 6){
					if(readbuf[5] == 3){
						if(count < 5){
							showProcessList("标定中...",Common.NULL,Common.OK);
							i--;
							count++;
							Commonfunc.sleep(1000);
						}else{
							showProcessList("标定失败",Common.NULL,Common.NG);
						}
					}else if(readbuf[5] == 2){
						showProcessList("执行完成",Common.NULL,Common.OK);
					}
				}else{//显示
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}


	private void fun_CX62_ReadDtc(Section section){
		String module="";
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				module = section.get("T" + i + "_MODULE");
				int select = cartype.getMap(module.substring(0, module.length() - 1));
				if(select == 0) continue;
				if(!SetCanInitial(module.substring(0, module.length() - 1) + select,canid)) continue;
				Commonfunc.sleep(Common.WAIT_TIME);

				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					continue;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				byte [] dtc = new byte[128];
				ArrayList<HashMap<String,String>> dtclist = new ArrayList<HashMap<String,String>>();
				dtc[0] = (byte) (((readbuf[0]&0xFF) - 3) / 4);
				System.arraycopy(readbuf, 4, dtc, 1, (dtc[0]&0xFF) * 4);
				dtclist = FileReader.readDtc(module, dtc, 3, false, false);
				if(dtclist.size() > 0){
					for(int z = 0; z < dtclist.size(); z ++){
						showProcessList(dtclist.get(z).get(Common.CONTENT),Common.NULL, Common.NG);
						mDtc.add(module.substring(0, module.length() - 1) + "--" + dtclist.get(z).get(Common.CONTENT));
					}
				}else{
					showProcessList("无故障",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_CX62B_ReadDtc(Section section){
		String module="";
		byte [] cmdlink = {0x02,0x10,0x03};
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				module = section.get("T" + i + "_MODULE");
				int select = cartype.getMap(module.substring(0, module.length() - 1));
				if(select == 0) continue;
				if(!SetCanInitial(module.substring(0, module.length() - 1) + select,canid)) continue;
				Commonfunc.sleep(Common.WAIT_TIME);
				if("TCU1".equals(module))
				{
					m_com.CanSendOneOnly(canid[0], cmdlink,cmdlink.length);
					Commonfunc.sleep(Common.WAIT_TIME);
				}

				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					continue;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				byte [] dtc = new byte[128];
				ArrayList<HashMap<String,String>> dtclist = new ArrayList<HashMap<String,String>>();
				dtc[0] = (byte) (((readbuf[0]&0xFF) - 3) / 4);
				System.arraycopy(readbuf, 4, dtc, 1, (dtc[0]&0xFF) * 4);
				if(i == 7){//EMS
					dtclist = FileReader.readEmsDtc(module, dtc, 3);
				}else{
					dtclist = FileReader.readDtc(module, dtc, 3, false, true);
				}
				if(dtclist.size() > 0){
					for(int z = 0; z < dtclist.size(); z ++){
						showProcessList(dtclist.get(z).get(Common.CONTENT),Common.NULL, Common.NG);
						mDtc.add(module.substring(0, module.length() - 1) + "--" + dtclist.get(z).get(Common.CONTENT));
					}
				}else{
					showProcessList("无故障",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_CX62_ReadConfig(Section section){
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				String module = section.get("T" + i + "_MODULE");
				int select = cartype.getMap(module.substring(0, module.length() - 1));
				if(select == 0)continue;
				if(!SetCanInitial(module.substring(0, module.length() - 1) + select,canid)) continue;
				Commonfunc.sleep(Common.WAIT_TIME);
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					continue;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				if(i == 1){
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.vin)){
						showProcessList(new String(vin),Common.NULL,Common.OK);
					}else{
						showProcessList(new String(vin),Common.NULL,Common.NG);
					}
				}else{
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.byteConfig)){
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL, Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL, Common.NG);
					}
				}
			}
		}
	}

	private void fun_KM23_ReadConfig(Section section){
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				String module = section.get("T" + i + "_MODULE");
				int select = cartype.getMap(module.substring(0, module.length() - 1));
				if(select == 0) continue;
				if(!SetCanInitial(module.substring(0, module.length() - 1) + select,canid)) continue;
				Commonfunc.sleep(Common.WAIT_TIME);
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					continue;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}

				byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
				System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
				if(Arrays.equals(vin, cartype.vin)){
					showProcessList(new String(vin),Common.NULL,Common.OK);
				}else{
					showProcessList(new String(vin),Common.NULL,Common.NG);
				}
			}
		}
	}

	private void fun_CX62B_ReadConfig(Section section){
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				String module = section.get("T" + i + "_MODULE");
				int select = cartype.getMap(module.substring(0, module.length() - 1));
				if(select == 0) continue;
				if(!SetCanInitial(module.substring(0, module.length() - 1) + select,canid)) continue;
				Commonfunc.sleep(Common.WAIT_TIME);
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					continue;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}

				if(i == 1){ //VIN
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.vin)){
						showProcessList(new String(vin),Common.NULL,Common.OK);
					}else{
						showProcessList(new String(vin),Common.NULL,Common.NG);
					}
				}else if(i == 12){
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.getWriteByte("TCM"))){
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.NG);
					}
				}else{
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.byteConfig)){
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL, Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL, Common.NG);
					}
				}
			}
		}
	}

	private void fun_KX63A_ReadConfig(Section section){
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6)) + 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				String module = section.get("T" + i + "_MODULE");
				int select = cartype.getMap(module.substring(0, module.length() - 1));
				if(select == 0) continue;
				if(!SetCanInitial(module.substring(0, module.length() - 1) + select,canid)) continue;
				Commonfunc.sleep(Common.WAIT_TIME);
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					continue;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}

				if(i == 1){ //VIN
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.vin)){
						showProcessList(new String(vin),Common.NULL,Common.OK);
					}else{
						showProcessList(new String(vin),Common.NULL,Common.NG);
					}
				}else if(i == 11){
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.getWriteByte("TCM"))){
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.NG);
					}
				}else{
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.byteConfig)){
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL, Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL, Common.NG);
					}
				}
			}
		}
	}



	private void fun_Q2020_EMS1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6))+ 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(cmd[1] == 0x27 && (cmd[2] == 0x02 || cmd[2] == 0x04)){ //安全认证

					if(cmd[0] == 0x06)
						Security.Chery_AECS_Standard_SafeKey(seed, key);
					else if(cmd[0] == 0x0A)
						Security.CX62_IMMO_Safekey(seed, key,0);
					else
						Security.LianDian_Standard_SafeKey(seed, key);
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				}else if(cmd[1] == 0x2E && (cmd[2]&0xFF) == 0xF1 && (cmd[3]&0xFF) == 0x90){ //写vin
					System.arraycopy(cartype.vin, 0, cmd, 4, cmd[0] - 3);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){ //通讯超时
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}

				if(cmd[1] == 0x27 && (cmd[2] == 0x01 || cmd[2] == 0x03)){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, readbuf[0] - 2);
				}else if(cmd[1] == 0x2E && (cmd[2]&0xFF) == 0xF1 && (cmd[3]&0xFF) == 0x90){ //
					showProcessList(new String(cartype.vin),Common.NULL, Common.OK);
				}else if(readbuf[1] == 0x62 && (readbuf[2]&0xFF) == 0xF1 && (readbuf[3]&0xFF) == 0x90)
				{ //读vin
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(cartype.vin, vin))
					{
						showProcessList(new String(vin),Common.NULL, Common.OK);
						if(stepName.indexOf("验证") >= 0)
							break;
					}else
					{
						if(stepName.indexOf("验证") >= 0) {
							//showProcessList(new String(vin), Common.NULL, Common.NULL);
						}
						else
							showProcessList(new String(vin),Common.NULL, Common.NG);
					}
				}else{
					showProcessList("",Common.NULL, Common.OK);
				}
			}
		}
	}

	private void fun_KQ92_EMS1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6))+ 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){ //安全认证
					Security.LianDian_Standard_SafeKey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 4);
				}else if(i == 6){ //写vin
					System.arraycopy(cartype.vin, 0, cmd, 4, 17);
				}
				else if(i == 10)
				{ //写sk
					if(cartype.getMap("IMMO") <= 0) break;
					if((cartype.pin[0] | cartype.pin[1]) == 0)
					{
						showProcessList("未获取PIN码!",Common.NULL,Common.NG);
						break;
					}
					System.arraycopy(cartype.pin, 0, cmd, 4, 4);
					System.arraycopy(cartype.pin, 0, cmd, 8, 4);
					System.arraycopy(cartype.pin, 0, cmd, 12, 4);
					System.arraycopy(cartype.pin, 0, cmd, 16, 4);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){ //通讯超时
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}

				if(i == 3){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, 4);
				}else if(i == 5 || i ==7){//读VIN
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.vin)){
						showProcessList(new String(vin),Common.NULL,Common.OK);
						if(i == 5){
							i += 2;
						}
					}else{
						if(Arrays.equals(vin, Common.ZERO) || Arrays.equals(vin, Common.FF)){
							showProcessList(new String(vin),Common.NULL,Common.OK);
						}else{
							showProcessList(new String(vin),Common.NULL,Common.NG);
						}
					}
				}else if(i == 9){
					byte [] dtc = new byte[128];
					ArrayList<HashMap<String,String>> dtclist = new ArrayList<HashMap<String,String>>();
					dtc[0] = (byte) (((readbuf[0]&0xFF) - 3) / 4);
					System.arraycopy(readbuf, 4, dtc, 1, (dtc[0]&0xFF) * 4);
					dtclist = FileReader.readDtc(section.get("MODULE"), dtc, 2, false, false);
					if(dtclist.size() > 0){
						for(int z = 0; z < dtclist.size(); z ++){
							showProcessList(dtclist.get(z).get(Common.CONTENT),Common.NULL, Common.NG);
							mDtc.add(section.get("MODULE").substring(0, section.get("MODULE").length() - 1) + "--" + dtclist.get(z).get(Common.CONTENT));
						}
					}else{
						showProcessList("无故障",Common.NULL,Common.OK);
					}
				}
				else if(i == 10)  //write sk
				{
					String v_show  = Commonfunc.bytesToHexString(cmd, 4,cmd[0] - 3);
					showProcessList(v_show,Common.NULL,Common.OK);
				}else if(i == 11) //read sk
				{
					String v_show  = Commonfunc.bytesToHexString(readbuf, 4,readbuf[0] - 3);
					showProcessList(v_show,Common.NULL,Common.OK);
				}
				else
				{
					showProcessList("",Common.NULL, Common.OK);
				}
			}
		}
	}

	private void fun_Q22LEV_EMS1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6))+ 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){ //安全认证
					Security.LianDian_Standard_SafeKey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 4);
				}else if(i == 6){ //写vin
					System.arraycopy(cartype.vin, 0, cmd, 4, 17);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){ //通讯超时
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}

				if(i == 3){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, 4);
				}else if(i == 5 || i ==7){//读VIN
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.vin)){
						showProcessList(new String(vin),Common.NULL,Common.OK);
						if(i == 5){
							i += 2;
						}
					}else{
						if(Arrays.equals(vin, Common.ZERO) || Arrays.equals(vin, Common.FF)){
							showProcessList(new String(vin),Common.NULL,Common.OK);
						}else{
							showProcessList(new String(vin),Common.NULL,Common.NG);
						}
					}
				}else if(i == 9){
					byte [] dtc = new byte[128];
					ArrayList<HashMap<String,String>> dtclist = new ArrayList<HashMap<String,String>>();
					dtc[0] = (byte) (((readbuf[0]&0xFF) - 3) / 4);
					System.arraycopy(readbuf, 4, dtc, 1, (dtc[0]&0xFF) * 4);
					dtclist = FileReader.readDtc(section.get("MODULE"), dtc, 2, false, false);
					if(dtclist.size() > 0){
						for(int z = 0; z < dtclist.size(); z ++){
							showProcessList(dtclist.get(z).get(Common.CONTENT),Common.NULL, Common.NG);
							mDtc.add(section.get("MODULE").substring(0, section.get("MODULE").length() - 1) + "--" + dtclist.get(z).get(Common.CONTENT));
						}
					}else{
						showProcessList("无故障",Common.NULL,Common.OK);
					}
				}else if(i == 10){//CAL ID
					byte [] vin = new byte[(readbuf[0]&0xFF) - 2];
					System.arraycopy(readbuf, 3, vin, 0, (readbuf[0]&0xFF) - 2);
					showProcessList(new String(vin),Common.NULL,Common.OK);
				}else if(i == 11){//CVN
					byte [] vin = new byte[(readbuf[0]&0xFF) - 2];
					System.arraycopy(readbuf, 3, vin, 0, (readbuf[0]&0xFF) - 2);
					showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL,Common.OK);
				}else{
					showProcessList("",Common.NULL, Common.OK);
				}
			}
		}
	}

	private void fun_KM23_EMS1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6))+ 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 5){ //安全认证
					Security.CX62_IMMO_Safekey(seed, key, 0);
					System.arraycopy(key, 0, cmd, 3, 8);
				}else if(i == 7){ //写vin
					System.arraycopy(cartype.vin, 0, cmd, 4, 17);
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){ //通讯超时
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}

				if(i == 4){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, 8);
				}else if(i == 2){//读VIN
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					showProcessList(new String(vin),Common.NULL,Common.OK);
				}else if(i == 6 || i == 8){//读VIN
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.vin)){
						showProcessList(new String(vin),Common.NULL,Common.OK);
						if(i == 6){
							i += 2;
						}
					}else{
						if(Arrays.equals(vin, Common.ZERO) || Arrays.equals(vin, Common.FF)){
							showProcessList(new String(vin),Common.NULL,Common.OK);
						}else{
							showProcessList(new String(vin),Common.NULL,Common.NG);
						}
					}
				}else{
					showProcessList("",Common.NULL, Common.OK);
				}
			}
		}
	}

	private void fun_KL33EV_BCM1(Section section){
		byte [] send = new byte[4];
		byte [] recv = new byte[4];
		if(!bluetooth.setCanInit_Exted(section.get("MODULE"), send, recv)) return;
		int time = 5;
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6))+ 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 5){ //安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}else if(i == 7){
					showTip("按开/闭锁键学习遥控..." + time + "S");
				}
				///////////////////////命令发送////////////////////////////////
				error = bluetooth.CanExtedMore2More((byte)0, (byte)0,(byte) 0, send, recv, cmd, readbuf, 2000, Common.CMD_MAX_TIME);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){ //通讯超时
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error > 0){//其他负响应
					showProcessList(Commonfunc.bytesToHexStringSpace(readbuf, 1,readbuf[0] + 1),Common.NULL, Common.NG);
					continue;
				}

				if(i == 3){ //复制SEED
					if(time >= 0){
						showTip("请关闭钥匙" + time +"S");
						Commonfunc.sleep(1000);
						time --;
						i--;
					}else{
						time = 8;
					}
				}else if(i == 4){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, 2);
				}else if(i == 6){//读VIN
					if(readbuf[5] == 2 || readbuf[5] == 1){
						showProcessList("",Common.NULL,Common.OK);
					}else{
						showProcessList("",Common.NULL,Common.NG);
					}
				}else if(i == 7){ //查询遥控钥匙学习结果
					if(time > 0){
						Commonfunc.sleep(900);
						time --;
						i --;
					}
				}else if(i == 9){ //读取学习钥匙数量
					if(readbuf[4] == 0x01 || (readbuf[4]&0xFF) == 0xCF){
						showProcessList("",Common.NULL,Common.OK);
					}else{
						showProcessList("",Common.NULL,Common.NG);
					}
				}else if(i == 11){//读dtc
					byte [] dtc = new byte[(readbuf[0]&0xFF) + 1];
					dtc[0] = (byte) (((readbuf[0]&0xFF)) / 4);
					System.arraycopy(readbuf, 4, dtc, 1, (readbuf[0]&0xFF));
					ArrayList<HashMap<String, String>> dtclist = FileReader.readDtc(section.get("MODULE"), dtc, 3);
					if(dtclist.size() > 0){
						for(int z = 0; z < dtclist.size(); z ++){
							showProcessList(dtclist.get(z).get(Common.CONTENT),Common.NULL, Common.NG);
							mDtc.add(section.get("MODULE").substring(0, section.get("MODULE").length() - 1) + "--" + dtclist.get(z).get(Common.CONTENT));
						}
					}else{
						showProcessList("无故障",Common.NULL,Common.OK);
					}
				}else if(i == 12){ //读取点火状态
					if(((readbuf[4] >> 3) & 0x01) != 0x01){ //ON
						showTip("开钥匙KEY ON...");
						Commonfunc.sleep(800);
						i --;
					}
				}else{
					showProcessList("",Common.NULL, Common.OK);
				}
			}
		}
	}

	private void fun_KL33EV_VCU1(Section section){
		byte [] send = new byte[4];
		byte [] recv = new byte[4];
		if(!bluetooth.setCanInit_Exted(section.get("MODULE"), send, recv)) return;
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6))+ 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4 || i == 9){ //安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}else if(i == 6){
					System.arraycopy(cartype.vin, 0, cmd, 4, 17);
				}else if(i == 10){
					System.arraycopy(cartype.byteConfig, 0, cmd, 4,cartype.byteConfig.length);;
				}
				///////////////////////命令发送////////////////////////////////
				error = bluetooth.CanExtedMore2More((byte)0, (byte)0,(byte) 0, send, recv, cmd, readbuf, 2000, Common.CMD_MAX_TIME);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){ //通讯超时
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error > 0){//其他负响应
					showProcessList(Commonfunc.bytesToHexStringSpace(readbuf, 1,readbuf[0] + 1),Common.NULL, Common.NG);
					continue;
				}

				if(i == 3 || i == 8){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, 2);
				}else if(i == 5 || i ==7){//读VIN
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.vin)){
						showProcessList(new String(vin),Common.NULL,Common.OK);
						if(i == 5){
							i += 2;
						}
					}else{
						showProcessList(new String(vin),Common.NULL,Common.NG);
					}
				}else if(i == 11){//读config
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.byteConfig)){
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL, Common.OK);
					}else{
						showProcessList(Commonfunc.bytesToHexString(vin, 0, vin.length),Common.NULL, Common.NG);
					}
				}else if(i == 13){//读dtc
					byte [] dtc = new byte[(readbuf[0]&0xFF) + 1];
					dtc[0] = (byte) (((readbuf[0]&0xFF)) / 4);
					System.arraycopy(readbuf, 4, dtc, 1, (readbuf[0]&0xFF));
					ArrayList<HashMap<String, String>> dtclist = FileReader.readDtc(section.get("MODULE"), dtc, 3);
					if(dtclist.size() > 0){
						for(int z = 0; z < dtclist.size(); z ++){
							showProcessList(dtclist.get(z).get(Common.CONTENT),Common.NULL, Common.NG);
							mDtc.add(section.get("MODULE").substring(0, section.get("MODULE").length() - 1) + "--" + dtclist.get(z).get(Common.CONTENT));
						}
					}else{
						showProcessList("无故障",Common.NULL,Common.OK);
					}
				}else{
					showProcessList("",Common.NULL, Common.OK);
				}
			}
		}
	}

	private void fun_KL33EV_MCU1(Section section){
		byte [] send = new byte[4];
		byte [] recv = new byte[4];
		if(!bluetooth.setCanInit_Exted(section.get("MODULE"), send, recv)) return;
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6))+ 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){ //安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}
				///////////////////////命令发送////////////////////////////////
				error = bluetooth.CanExtedMore2More((byte)0, (byte)0,(byte) 0, send, recv, cmd, readbuf, 2000, Common.CMD_MAX_TIME);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){ //通讯超时
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error > 0){//其他负响应
					showProcessList(Commonfunc.bytesToHexStringSpace(readbuf, 1,readbuf[0] + 1),Common.NULL, Common.NG);
					continue;
				}

				if(i == 3){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, 2);
				}else if(i == 6){//读dtc
					byte [] dtc = new byte[(readbuf[0]&0xFF) + 1];
					dtc[0] = (byte) (((readbuf[0]&0xFF)) / 4);
					System.arraycopy(readbuf, 4, dtc, 1, (readbuf[0]&0xFF));
					ArrayList<HashMap<String, String>> dtclist = FileReader.readDtc(section.get("MODULE"), dtc, 3);
					if(dtclist.size() > 0){
						for(int z = 0; z < dtclist.size(); z ++){
							showProcessList(dtclist.get(z).get(Common.CONTENT),Common.NULL, Common.NG);
							mDtc.add(section.get("MODULE").substring(0, section.get("MODULE").length() - 1) + "--" + dtclist.get(z).get(Common.CONTENT));
						}
					}else{
						showProcessList("无故障",Common.NULL,Common.OK);
					}
				}else{
					showProcessList("",Common.NULL, Common.OK);
				}
			}
		}
	}

	private void fun_KL33EV_TBOX1(Section section){
		byte [] send = new byte[4];
		byte [] recv = new byte[4];
		if(!bluetooth.setCanInit_Exted(section.get("MODULE"), send, recv)) return;
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6))+ 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i == 4){ //安全认证
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, 2);
				}else if(i == 6){
					System.arraycopy(cartype.vin, 0, cmd, 4, 17);
				}
				///////////////////////命令发送////////////////////////////////
				error = bluetooth.CanExtedMore2More((byte)0, (byte)0,(byte) 0, send, recv, cmd, readbuf, 2000, Common.CMD_MAX_TIME);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){ //通讯超时
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error > 0){//其他负响应
					showProcessList(Commonfunc.bytesToHexStringSpace(readbuf, 1,readbuf[0] + 1),Common.NULL, Common.NG);
					continue;
				}

				if(i ==3){ //复制SEED
					System.arraycopy(readbuf, 3, seed, 0, 2);
				}else if(i == 5 || i ==7){//读VIN
					byte [] vin = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, vin, 0, (readbuf[0]&0xFF) - 3);
					if(Arrays.equals(vin, cartype.vin)){
						showProcessList(new String(vin),Common.NULL,Common.OK);
						if(i == 5){
							i += 2;
						}
					}else{
						showProcessList(new String(vin),Common.NULL,Common.NG);
					}
				}else if(i == 8){//读Ver
					byte [] ver = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, ver, 0, (readbuf[0]&0xFF) - 3);
					showProcessList(new String(ver),Common.NULL,Common.OK);
				}else if(i == 10){//读dtc
					byte [] dtc = new byte[(readbuf[0]&0xFF) + 1];
					dtc[0] = (byte) (((readbuf[0]&0xFF)) / 4);
					System.arraycopy(readbuf, 4, dtc, 1, (readbuf[0]&0xFF));
					ArrayList<HashMap<String, String>> dtclist = FileReader.readDtc(section.get("MODULE"), dtc, 3);
					if(dtclist.size() > 0){
						for(int z = 0; z < dtclist.size(); z ++){
							showProcessList(dtclist.get(z).get(Common.CONTENT),Common.NULL, Common.NG);
							mDtc.add(section.get("MODULE").substring(0, section.get("MODULE").length() - 1) + "--" + dtclist.get(z).get(Common.CONTENT));
						}
					}else{
						showProcessList("无故障",Common.NULL,Common.OK);
					}
				}else{
					showProcessList("",Common.NULL, Common.OK);
				}
			}
		}
	}

	private void fun_KL33EV_ACM1(Section section){
		byte [] send = new byte[4];
		byte [] recv = new byte[4];
		if(!bluetooth.setCanInit_Exted(section.get("MODULE"), send, recv)) return;
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6))+ 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				///////////////////////命令发送////////////////////////////////
				error = bluetooth.CanExtedMore2More((byte)0, (byte)0,(byte) 0, send, recv, cmd, readbuf, 2000, Common.CMD_MAX_TIME);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){ //通讯超时
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error > 0){//其他负响应
					showProcessList(Commonfunc.bytesToHexStringSpace(readbuf, 1,readbuf[0] + 1),Common.NULL, Common.NG);
					continue;
				}

				if(i == 4){//读dtc
					byte [] dtc = new byte[(readbuf[0]&0xFF) + 1];
					dtc[0] = (byte) (((readbuf[0]&0xFF)) / 4);
					System.arraycopy(readbuf, 4, dtc, 1, (readbuf[0]&0xFF));
					ArrayList<HashMap<String, String>> dtclist = FileReader.readDtc(section.get("MODULE"), dtc, 3);
					if(dtclist.size() > 0){
						for(int z = 0; z < dtclist.size(); z ++){
							showProcessList(dtclist.get(z).get(Common.CONTENT),Common.NULL, Common.NG);
							mDtc.add(section.get("MODULE").substring(0, section.get("MODULE").length() - 1) + "--" + dtclist.get(z).get(Common.CONTENT));
						}
					}else{
						showProcessList("无故障",Common.NULL,Common.OK);
					}
				}else if(i == 5){//读Ver
					byte [] ver = new byte[(readbuf[0]&0xFF) - 3];
					System.arraycopy(readbuf, 4, ver, 0, (readbuf[0]&0xFF) - 3);
					showProcessList(new String(ver),Common.NULL,Common.OK);
				}else{
					showProcessList("",Common.NULL, Common.OK);
				}
			}
		}
	}

	private void fun_KQ92_ABS1(Section section){
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6))+ 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){ //通讯超时
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					return;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}

				if(i == 4){
					byte [] dtc = new byte[128];
					ArrayList<HashMap<String,String>> dtclist = new ArrayList<HashMap<String,String>>();
					dtc[0] = (byte) (((readbuf[0]&0xFF) - 3) / 4);
					System.arraycopy(readbuf, 4, dtc, 1, (dtc[0]&0xFF) * 4);
					dtclist = FileReader.readDtc(section.get("MODULE"), dtc, 2, false, false);
					if(dtclist.size() > 0){
						for(int z = 0; z < dtclist.size(); z ++){
							showProcessList(dtclist.get(z).get(Common.CONTENT),Common.NULL, Common.NG);
							mDtc.add(section.get("MODULE").substring(0, section.get("MODULE").length() - 1) + "--" + dtclist.get(z).get(Common.CONTENT));
						}
					}else{
						showProcessList("无故障",Common.NULL,Common.OK);
					}
				}else{
					showProcessList("",Common.NULL, Common.OK);
				}
			}
		}
	}




	private void fun_Standard_ClearDtc(Section section){
		String module = "" ;
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6))+ 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				//这里先判断是否存在该模块
				module = section.get("T" + i + "_MODULE");
				int select = cartype.getMap(module.substring(0, module.length() - 1));
				if(select == 0) continue;

				if(!SetCanInitial(module.substring(0, module.length() - 1) + select,canid)) continue;
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					continue;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}

				showProcessList("",Common.NULL, Common.OK);
			}
		}
	}

	private void fun_Standard_ReadInfo(Section section){
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6))+ 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i % 3 == 1){
					String module = section.get("T" + i + "_MODULE");
					int select = cartype.getMap(module.substring(0, module.length()-1));
					if(select == 0){
						i += 2;
						continue;
					}
					if(!SetCanInitial(module.substring(0, module.length() - 1) + select,canid)) continue;
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					if(i % 3 == 1){
						i += 2;
					}else if(i % 3 == 2){
						i += 1;
					}
					continue;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				byte [] version = new byte[(readbuf[0]&0xFF) - 3];
				System.arraycopy(readbuf, 4, version, 0, (readbuf[0]&0xFF) - 3);
				showProcessList(new String(version),Common.NULL, Common.OK);
			}
		}
	}

	private void fun_KX63_ReadInfo(Section section){
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){
				byte [] cmd = new byte[Commonfunc.hexStringtoInt(stepType.substring(4, 6))+ 1];
				Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);
				///////////////////////命令发送前////////////////////////////////
				if(i % 2 == 1){
					String module = section.get("T" + i + "_MODULE");
					int select = cartype.getMap(module.substring(0, module.length()-1));
					if(select == 0){
						i ++;
						continue;
					}
					if(!SetCanInitial(module.substring(0, module.length() - 1) + select,canid)) continue;
				}
				///////////////////////命令发送////////////////////////////////
				error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					if(i % 2 == 1){
						i ++;
					}
					continue;
				}else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				byte [] version = new byte[(readbuf[0]&0xFF) - 3];
				System.arraycopy(readbuf, 4, version, 0, (readbuf[0]&0xFF) - 3);
				showProcessList(new String(version),Common.NULL, Common.OK);
			}
		}
	}

	private void fun_Q2020_ClearDtc(Section section){
		String module = "" ;
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				int cmdlen = Commonfunc.hexStringtoInt(stepType.substring(4, 6));
				///////////////////////命令发送////////////////////////////////
				if(i > 2){
					byte [] cmd = new byte[cmdlen + 1];
					Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);

					module = section.get("T" + i + "_MODULE");
					int select = cartype.getMap(module.substring(0, module.length() - 1));
					if(select == 0) continue;
					if(!SetCanInitial(module.substring(0, module.length() - 1) + select,canid)) continue;

					error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				}else{//K线
					byte [] cmd = new byte[cmdlen];
					Commonfunc.cmdStringToBytes(stepType.substring(7), cmd);
					if(i == 1){
						module = section.get("T" + i + "_MODULE");
						int select = cartype.getMap(module.substring(0, module.length() - 1));
						if(module.equals(module.substring(0, module.length() - 1) + select) == false){
							i++;
							continue;
						}
						error = bluetooth.kwpFastConnect(10400, 0, cmd,  readbuf, Common.CMD_MAX_TIME,  5004);
					}else if(i == 2){
						error = bluetooth.kwpOneToOne(cmd, readbuf, Common.CMD_MAX_TIME, 5004);
					}
				}
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					if(i == 1){
						i++;
					}
					continue;
				}else if(error > 0){//其他负响应
					showProcessList(Commonfunc.bytesToHexString(readbuf, 1, readbuf[0] + 1),Common.NULL, Common.NG);
					if(i == 1){
						i++;
					}
					continue;
				}

				showProcessList("",Common.NULL, Common.OK);
			}
		}
	}

	private void fun_KM23_ClearDtc(Section section){
		String module = "" ;
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				int cmdlen = Commonfunc.hexStringtoInt(stepType.substring(4, 6));
				///////////////////////命令发送////////////////////////////////
				if(i > 2){
					byte [] cmd = new byte[cmdlen + 1];
					Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);

					module = section.get("T" + i + "_MODULE");
					int select = cartype.getMap(module.substring(0, module.length() - 1));
					if(select == 0) continue;
					if(!SetCanInitial(module.substring(0, module.length() - 1) + select,canid)) continue;

					error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				}else{//K线
					byte [] cmd = new byte[cmdlen];
					Commonfunc.cmdStringToBytes(stepType.substring(7), cmd);
					if(i == 1){
						module = section.get("T" + i + "_MODULE");
						int select = cartype.getMap(module.substring(0, module.length() - 1));
						if(module.equals(module.substring(0, module.length() - 1) + select) == false){
							i++;
							continue;
						}
						error = bluetooth.kwpFastConnect(10400, 0, cmd,  readbuf, Common.CMD_MAX_TIME,  5004);
					}else if(i == 2){
						error = bluetooth.kwpOneToOne(cmd, readbuf, Common.CMD_MAX_TIME, 5004);
					}
				}
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					if(i == 1){
						i++;
					}
					continue;
				}else if(error > 0){//其他负响应
					showProcessList(Commonfunc.bytesToHexString(readbuf, 1, readbuf[0] + 1),Common.NULL, Common.NG);
					if(i == 1){
						i++;
					}
					continue;
				}

				showProcessList("",Common.NULL, Common.OK);
			}
		}
	}

	private void fun_Q22LEV_ClearDtc(Section section){
		String module = "" ;
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				int cmdlen = Commonfunc.hexStringtoInt(stepType.substring(4, 6));
				///////////////////////命令发送////////////////////////////////
				if(i > 4){
					byte [] cmd = new byte[cmdlen + 1];
					Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);

					module = section.get("T" + i + "_MODULE");
					int select = cartype.getMap(module.substring(0, module.length() - 1));
					if(select == 0) continue;
					if(!SetCanInitial(module.substring(0, module.length() - 1) + select,canid)) continue;

					error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				}else{//K线
					byte [] cmd = new byte[cmdlen];
					Commonfunc.cmdStringToBytes(stepType.substring(7), cmd);
					if(i == 1 || i ==3){
						module = section.get("T" + i + "_MODULE");
						int select = cartype.getMap(module.substring(0, module.length() - 1));
						if(module.equals(module.substring(0, module.length() - 1) + select) == false){
							i++;
							continue;
						}
						error = bluetooth.kwpFastConnect(10400, 0, cmd,  readbuf, Common.CMD_MAX_TIME,  5004);
					}else if(i == 2 || i == 4){
						error = bluetooth.kwpOneToOne(cmd, readbuf, Common.CMD_MAX_TIME, 5004);
					}
				}
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					if(i == 1 || i ==3){
						i++;
					}
					continue;
				}else if(error > 0){//其他负响应
					showProcessList(Commonfunc.bytesToHexString(readbuf, 1, readbuf[0] + 1),Common.NULL, Common.NG);
					if(i == 1 || i ==3){
						i++;
					}
					continue;
				}
				showProcessList("",Common.NULL, Common.OK);
			}
		}
	}


	private void fun_Q2020_ReadDtc(Section section){
		String module="";
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				int cmdlen = Commonfunc.hexStringtoInt(stepType.substring(4, 6));
				///////////////////////命令发送////////////////////////////////
				if(i > 2){
					byte [] cmd = new byte[cmdlen + 1];
					Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);

					module = section.get("T" + i + "_MODULE");
					int select = cartype.getMap(module.substring(0, module.length() - 1));
					if(select == 0) continue;
					if(!SetCanInitial(module.substring(0, module.length() - 1) + select,canid)) continue;
					error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				}else{//K线
					byte [] cmd = new byte[cmdlen];
					Commonfunc.cmdStringToBytes(stepType.substring(7), cmd);
					if(i==1){
						module = section.get("T" + i + "_MODULE");
						int select = cartype.getMap(module.substring(0, module.length() - 1));
						if(module.equals(module.substring(0, module.length() - 1) + select) == false){
							i++;
							continue;
						}
						error = bluetooth.kwpFastConnect(10400, 0, cmd, readbuf, Common.CMD_MAX_TIME, 5004);
					}else if(i==2){
						error = bluetooth.kwpOneToOne(cmd, readbuf, Common.CMD_MAX_TIME, 5004);
					}
				}
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					if(i == 1){
						i++;
					}
					continue;
				}else if(error > 0){
					showProcessList(Commonfunc.bytesToHexStringSpace(readbuf, 1,readbuf[0] + 1),Common.NULL, Common.NG);
					if(i == 1){
						i++;
					}
					continue;
				}
				if(i == 1){
					continue;
				}
				byte [] dtc = new byte[512];
				ArrayList<HashMap<String,String>> dtclist = new ArrayList<HashMap<String,String>>();
				if(i == 2){
					dtc[0] = (byte) (((readbuf[2]&0xFF)-0x80-3)/4);
					for(int k = 0; k < dtc[0]; k ++){
						System.arraycopy(readbuf, 7 + k * 3, dtc, 1 + k * 4, 2);
						dtc[1 + k * 4 + 2] = 0;
						dtc[1 + k * 4 + 3] = readbuf[7 + k * 3 + 2];
					}
					dtclist = FileReader.readDtc(module, dtc, 3, false, false);
				}else{
					dtc[0] = (byte) (((readbuf[0]&0xFF) - 3) / 4);
					System.arraycopy(readbuf, 4, dtc, 1, (dtc[0]&0xFF) * 4);
					dtclist = FileReader.readDtc(module, dtc, 3, false, false);
				}

				if(dtclist.size() > 0){
					for(int z = 0; z < dtclist.size(); z ++){
						showProcessList(dtclist.get(z).get(Common.CONTENT),Common.NULL, Common.NG);
						mDtc.add(module.substring(0, module.length() - 1) + "--" + dtclist.get(z).get(Common.CONTENT));
					}
				}else{
					showProcessList("无故障",Common.NULL, Common.OK);
				}
			}
		}
	}

	private void fun_KM23_ReadDtc(Section section){
		String module="";
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				int cmdlen = Commonfunc.hexStringtoInt(stepType.substring(4, 6));
				///////////////////////命令发送////////////////////////////////
				if(i > 2){
					byte [] cmd = new byte[cmdlen + 1];
					Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);

					module = section.get("T" + i + "_MODULE");
					int select = cartype.getMap(module.substring(0, module.length() - 1));
					if(select == 0) continue;
					if(!SetCanInitial(module.substring(0, module.length() - 1) + select,canid)) continue;
					error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				}else{//K线
					byte [] cmd = new byte[cmdlen];
					Commonfunc.cmdStringToBytes(stepType.substring(7), cmd);
					if(i==1){
						module = section.get("T" + i + "_MODULE");
						int select = cartype.getMap(module.substring(0, module.length() - 1));
						if(module.equals(module.substring(0, module.length() - 1) + select) == false){
							i++;
							continue;
						}
						error = bluetooth.kwpFastConnect(10400, 0, cmd, readbuf, Common.CMD_MAX_TIME, 5004);
					}else if(i==2){
						error = bluetooth.kwpOneToOne(cmd, readbuf, Common.CMD_MAX_TIME, 5004);
					}
				}
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					if(i == 1){
						i++;
					}
					continue;
				}else if(error > 0){
					showProcessList(Commonfunc.bytesToHexStringSpace(readbuf, 1,readbuf[0] + 1),Common.NULL, Common.NG);
					if(i == 1){
						i++;
					}
					continue;
				}
				if(i == 1){
					continue;
				}
				byte [] dtc = new byte[512];
				ArrayList<HashMap<String,String>> dtclist = new ArrayList<HashMap<String,String>>();
				if(i == 2){
					dtc[0] = (byte) (((readbuf[2]&0xFF)-0x80-3)/4);
					for(int k = 0; k < dtc[0]; k ++){
						System.arraycopy(readbuf, 7 + k * 3, dtc, 1 + k * 4, 2);
						dtc[1 + k * 4 + 2] = 0;
						dtc[1 + k * 4 + 3] = readbuf[7 + k * 3 + 2];
					}
					dtclist = FileReader.readDtc(module, dtc, 3, false, false);
				}else{
					dtc[0] = (byte) (((readbuf[0]&0xFF) - 3) / 4);
					System.arraycopy(readbuf, 4, dtc, 1, (dtc[0]&0xFF) * 4);
					dtclist = FileReader.readDtc(module, dtc, 3, false, false);
				}

				if(dtclist.size() > 0){
					for(int z = 0; z < dtclist.size(); z ++){
						showProcessList(dtclist.get(z).get(Common.CONTENT),Common.NULL, Common.NG);
						mDtc.add(module.substring(0, module.length() - 1) + "--" + dtclist.get(z).get(Common.CONTENT));
					}
				}else{
					showProcessList("无故障",Common.NULL, Common.OK);
				}
			}
		}
	}

	private void fun_Q22LEV_ReadDtc(Section section){
		String module="";
		for(int i = 1; i < (num + 1); i ++){
			if(exit) return;
			stepType = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(stepType.length() < 3) continue;
			if(stepType.substring(0, 3).equals("CMD")){  //cmd
				int cmdlen = Commonfunc.hexStringtoInt(stepType.substring(4, 6));
				///////////////////////命令发送////////////////////////////////
				if(i > 4){
					byte [] cmd = new byte[cmdlen + 1];
					Commonfunc.cmdStringToBytes(stepType.substring(4), cmd);

					module = section.get("T" + i + "_MODULE");
					int select = cartype.getMap(module.substring(0, module.length() - 1));
					if(select == 0) continue;
					if(!SetCanInitial(module.substring(0, module.length() - 1) + select,canid)) continue;
					error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmd.length, readbuf, 5003, Common.CMD_MAX_TIME, 2);
				}else{//K线
					byte [] cmd = new byte[cmdlen];
					Commonfunc.cmdStringToBytes(stepType.substring(7), cmd);
					if(i == 1 || i == 3){
						module = section.get("T" + i + "_MODULE");
						int select = cartype.getMap(module.substring(0, module.length() - 1));
						if(module.equals(module.substring(0, module.length() - 1) + select) == false){
							i++;
							continue;
						}
						error = bluetooth.kwpFastConnect(10400, 0, cmd, readbuf, Common.CMD_MAX_TIME, 5004);
					}else if(i == 2 || i == 4){
						error = bluetooth.kwpOneToOne(cmd, readbuf, Common.CMD_MAX_TIME, 5004);
					}
				}
				///////////////////////命令错误处理////////////////////////////////
				if(error == 5001){
					showProcessList("通讯超时!",Common.NULL, Common.NG);
					if(i == 1 || i == 3){
						i++;
					}
					continue;
				}else if(error > 0){
					showProcessList(Commonfunc.bytesToHexStringSpace(readbuf, 1,readbuf[0] + 1),Common.NULL, Common.NG);
					if(i == 1 || i == 3){
						i++;
					}
					continue;
				}
				if(i == 1 || i == 3){
					continue;
				}
				byte [] dtc = new byte[512];
				ArrayList<HashMap<String,String>> dtclist = new ArrayList<HashMap<String,String>>();
				if(i == 2 || i == 4){
					dtc[0] = (byte) (((readbuf[2]&0xFF)-0x80-3)/4);
					for(int k = 0; k < dtc[0]; k ++){
						System.arraycopy(readbuf, 7 + k * 3, dtc, 1 + k * 4, 2);
						dtc[1 + k * 4 + 2] = 0;
						dtc[1 + k * 4 + 3] = readbuf[7 + k * 3 + 2];
					}
					dtclist = FileReader.readDtc(module, dtc, 3, false, false);
				}else{
					dtc[0] = (byte) (((readbuf[0]&0xFF) - 3) / 4);
					System.arraycopy(readbuf, 4, dtc, 1, (dtc[0]&0xFF) * 4);
					dtclist = FileReader.readDtc(module, dtc, 3, false, false);
				}

				if(dtclist.size() > 0){
					for(int z = 0; z < dtclist.size(); z ++){
						showProcessList(dtclist.get(z).get(Common.CONTENT),Common.NULL, Common.NG);
						mDtc.add(module.substring(0, module.length() - 1) + "--" + dtclist.get(z).get(Common.CONTENT));
					}
				}else{
					showProcessList("无故障",Common.NULL, Common.OK);
				}
			}
		}
	}

	private void fun_T1P_Stand_ReadInfo(Section Pstep)
	{
		int num = Integer.valueOf(Pstep.get("NUM"));
		int Pid = Integer.valueOf(Pstep.get("MODULE_ID"));
		int v_req = 0;
		int v_res = 0;
		int v_lastmode = 0;
		String step_t = null;
		//String step_name = null;
		String v_module = null;
		byte [] Readbuf = new byte[512];
		int error = 0;
		int v_len = 0;
		int v_find_k = 0; //K线标致
		byte [] cmdlink = {0x02,0x10,0x03};
		SetCanInitTimer(10);
		stepId = Integer.valueOf(Pstep.get("MODULE_ID"));
		for(int i = 1; i < (num + 1); i ++)
		{
			step_t = Pstep.get("T" + i);
			stepName = Pstep.get("T" + i + "_NAME");
			if(stepName == null) continue;
			//获取模块名字
			v_len = stepName.indexOf("-");
			v_find_k = stepName.indexOf("-k");
			if(v_find_k > 0) continue;
			v_module = stepName.substring(0,v_len);
			if(step_t == null) continue;
			if(step_t.length() < 3) continue;
			if(step_t.substring(0, 3).equals("CMD"))  //cmd
			{
				int cmdlen = Commonfunc.hexStringtoInt(step_t.substring(4, 6)) + 1;
				byte [] cmd = new byte[cmdlen];
				if(Commonfunc.CmdStringToBytes(step_t.substring(4), cmd, cmdlen) != cmd.length) continue;
				//---------------------发送前处理---------------------
				//确认模块
				v_len = cartype.getMap(v_module);
				if(v_len <= 0) continue;
				//得到CAN ID
				Can can = cartype.getCan(v_module + v_len);
				if(can == null) continue;
				if(can.getMode() != v_lastmode)
				{
					v_lastmode = can.getMode();
					SetCanMode(v_lastmode,can.getBaud());
				}
				if(can != null)  //todo bluetooth
				{
					v_req = can.getSendid();
					v_res = can.getRecvid();
				}
				else
					continue;
				if("TCU".equals(v_module))
				{
					m_com.CanOne2OneUDS(v_req, v_res, cmdlink,cmdlink.length, Readbuf, 5003, 1500, 2);
					Commonfunc.sleep(Common.WAIT_TIME);
					if((cmd[3]&0xFF) == 0x88)
					{
						if(cartype.getMap("1.6T") == 1)
							cmd[3] = (byte) 0x95;
					}
				}
				//Sleep(10);

				//特殊处理多次发送命令
				if(v_req == 0x760 || v_req == 0x7E2)
				{
					error = m_com.CanOne2OneUDS(v_req, v_res, cmd,cmdlen, Readbuf, 5003, 5000, 2);
				}
				else //普通发送命令
				{
					error = m_com.CanOne2OneUDS(v_req, v_res, cmd,cmdlen, Readbuf, 5003, 1500, 2);
				}
				Commonfunc.sleep(Common.WAIT_TIME);
				//错误处理
				if(error == 5001) //通讯超时
				{
					showProcessList("通讯超时!",Common.NULL,Common.NG);
					continue;
				}
				else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((Readbuf[1]&0xFF) == 0x7F) //异常
					{
						if((Readbuf[3]&0xFF) == 0x31) continue;
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				//特殊处理返回结果
				if(Readbuf[1] == 0x54) //清故障码
				{
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x59) //读故障码
				{
					byte [] dtc = new byte[512];
					ArrayList<HashMap<String,String>> dtclist = new ArrayList<HashMap<String,String>>();

					dtc[0] = (byte) (((Readbuf[0]&0xFF) - 3) / 4);
					System.arraycopy(Readbuf, 4, dtc, 1, (dtc[0]&0xFF) * 4);
					dtclist = FileReader.readDtc(v_module + v_len, dtc, 3, false, false);

					if(dtclist.size() > 0){
						for(int z = 0; z < dtclist.size(); z ++){
							showProcessList(dtclist.get(z).get(Common.CONTENT),Common.NULL, Common.NG);
							mDtc.add(v_module + "--" + dtclist.get(z).get(Common.CONTENT));
						}
					}else{
						showProcessList("无故障",Common.NULL, Common.OK);
					}
				}
				else if(Readbuf[1] == 0x62) //读数据
				{
					byte [] v_data = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf, 4, v_data, 0, Readbuf[0] - 3);
					String v_show = "";
					String v_get = "";
					String v_get1 = "";
					boolean isver = false;
					int v_code = (Readbuf[2]&0xFF) * 0x100 + (Readbuf[3]&0xFF);
					switch(v_code)
					{
						case 0xF190:
							v_show = new String(v_data);
							v_get = new String(cartype.vin);
							break;
						case 0xF187: //partnumber
						case 0xF19E:
						case 0xF013:
							v_show = new String(v_data);
							v_get = CommonXml.GetEcuInfoSn(cartype.mesinfo, v_module);
							isver =true;
							break;
						case 0xF191:   //hard version
						case 0xF192:
						case 0xF193:
							v_show = new String(v_data);
							v_get = CommonXml.GetEcuInfoHard(cartype.mesinfo, v_module);
							//v_get1 = CommonXml.GetEcuInfoHard(cartype.mesinfo, v_module,1);
							isver =true;
							break;
						case 0xF194:   //soft version
						case 0xF195:
						case 0xF188:
							v_show = new String(v_data);
							if(v_module.equals("GBC") && v_code == 0xF194)
							{
								v_get = CommonXml.GetEcuInfoHard(cartype.mesinfo, v_module);
								//v_get1 = CommonXml.GetEcuInfoHard(cartype.mesinfo, v_module,1);
							}
							else
							{
								v_get = CommonXml.GetEcuInfoSoft(cartype.mesinfo, v_module);
								//v_get1 = CommonXml.GetEcuInfoSoft(cartype.mesinfo, v_module,1);
							}
							isver =true;
							break;
						case 0xD009:  //配置码
						case 0x3011:
						case 0x7601:
						case 0x3801:
						case 0x7407:
						case 0xD008:
							v_show = Commonfunc.bytesToHexString(v_data, 0, v_data.length);
							v_get = Commonfunc.bytesToHexString(cartype.byteConfig,0,v_data.length);
							if (v_module.equals("FRM")){
								v_get = Commonfunc.bytesToHexString(cartype.byteConfig,167,167+v_data.length);
							}
							if (v_module.equals("IHU")){
								v_get = Commonfunc.bytesToHexString(cartype.byteConfig,66,66+v_data.length);
							} else if (v_module.equals("AMP")) {
								v_get = Commonfunc.bytesToHexString(cartype.byteConfig,116,116+v_data.length);
							} else if (v_module.equals("TCU")) {
								v_get = Commonfunc.bytesToHexString(cartype.byteConfig,11,11+v_data.length);
							} else if (cartype.car.equals("T1PPHEV")&&v_module.equals("CLM")) {
								v_get = Commonfunc.bytesToHexString(cartype.byteConfig,98,98+v_data.length);
							}
							v_get1 = "config";
							break;
						case 0x5515:  //BTM
						case 0x5514:
						case 0x5511:
						case 0x5512:
						case 0x5513:
							v_show = new String(v_data);
							v_get = "OK";
							break;
					}
					if(v_module.equals("TBOX"))
					{
						v_get1 += "";;
					}
					v_show = v_show.replaceAll(" ", "");
					v_show = v_show.trim();
					if(v_get1.equals("config")) //配置
					{
						if(v_show.equals(v_get))
							showProcessList(v_show,v_get,Common.OK);
						else
							showProcessList(v_show ,v_get,Common.NG);
					}
					else if(isver == true)
					{
						if(v_get != null && (v_get.indexOf(v_show) >= 0) && (v_show.length() > 0))
							showProcessList(v_show ,v_get,Common.OK);
						else if(v_get.length() < 2)
						{
							showProcessList(v_show,"MES:无数据",Common.NULL);
						}
						else
							showProcessList(v_show ,v_get,Common.NG);

					}
					else if(isver == false)
					{
						if(v_show.equals(v_get))
							showProcessList(v_show,v_get,Common.OK);
						else
							showProcessList(v_show,v_get,Common.NG);
					}
					else
						showProcessList(v_show,Common.NULL,Common.NULL);
				}
			}
		}
	}

	private void fun_T1N_Stand_ReadInfo(Section Pstep)
	{
		int num = Integer.valueOf(Pstep.get("NUM"));
		int Pid = Integer.valueOf(Pstep.get("MODULE_ID"));
		int v_req = 0;
		int v_res = 0;
		int v_lastmode = 0;
		String step_t = null;
		//String step_name = null;
		String v_module = null;
		byte [] Readbuf = new byte[512];
		int error = 0;
		int v_len = 0;
		int v_find_k = 0; //K线标致
		byte [] cmdlink = {0x02,0x10,0x03};
		SetCanInitTimer(10);
		for(int i = 1; i < (num + 1); i ++)
		{
			step_t = Pstep.get("T" + i);
			stepName = Pstep.get("T" + i + "_NAME");
			if(stepName == null) continue;
			//获取模块名字
			v_len = stepName.indexOf("-");
			v_find_k = stepName.indexOf("-k");
			if(v_find_k > 0) continue;
			v_module = stepName.substring(0,v_len);
			if(step_t == null) break;
			if(step_t.length() < 3) continue;
			if(step_t.substring(0, 3).equals("CMD"))  //cmd
			{
				//获取cmd长度
				int cmdlen = Commonfunc.hexStringtoInt(step_t.substring(4, 6)) + 1;
				byte [] cmd = new byte[cmdlen];
				if(Commonfunc.CmdStringToBytes(step_t.substring(4), cmd, cmdlen) != cmd.length) return;
				//---------------------发送前处理---------------------
				//确认模块
				v_len = cartype.getMap(v_module);
				if(v_len <= 0) continue;
				//得到CAN ID
				Can can = cartype.getCan(v_module + v_len);
				if(can == null) continue;
				if(can.getMode() != v_lastmode)   // todo bluetooth
				{
					v_lastmode = can.getMode();
					SetCanMode(v_lastmode,can.getBaud());
				}
				if(can != null)
				{
					v_req = can.getSendid();
					v_res = can.getRecvid();
				}
				else
					continue;
				if("TCU".equals(v_module))
				{
					m_com.CanOne2OneUDS(v_req, v_res, cmdlink,cmdlink.length, Readbuf, 5003, 1500, 2);
					Commonfunc.sleep(Common.WAIT_TIME);
				}
				showTip(stepName + "...");
				//Sleep(10);

				//特殊处理多次发送命令
				if(v_req == 0x760 || v_req == 0x7E2)
				{
					error = m_com.CanOne2OneUDS(v_req, v_res, cmd,cmdlen, Readbuf, 5003, 5000, 2);
				}
				else //普通发送命令
				{
					error = m_com.CanOne2OneUDS(v_req, v_res, cmd,cmdlen, Readbuf, 5003, 1500, 2);
				}
				Commonfunc.sleep(Common.WAIT_TIME);
				//错误处理
				if(error == 5001) //通讯超时
				{
					showProcessList("通讯超时!",Common.NULL,Common.NG);
					continue;
				}
				else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((Readbuf[1]&0xFF) == 0x7F) //异常
					{
						if((Readbuf[3]&0xFF) == 0x31) continue;
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				//特殊处理返回结果
				if(Readbuf[1] == 0x54) //清故障码
				{
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x59) //读故障码
				{
					byte [] dtc = new byte[512];
					ArrayList<HashMap<String,String>> dtclist = new ArrayList<HashMap<String,String>>();

					dtc[0] = (byte) (((Readbuf[0]&0xFF) - 3) / 4);
					System.arraycopy(Readbuf, 4, dtc, 1, (dtc[0]&0xFF) * 4);
					dtclist = FileReader.readDtc(v_module + v_len, dtc, 3, false, false);

					if(dtclist.size() > 0){
						for(int z = 0; z < dtclist.size(); z ++){
							showProcessList(dtclist.get(z).get(Common.CONTENT),Common.NULL, Common.NG);
							mDtc.add(v_module + "--" + dtclist.get(z).get(Common.CONTENT));
						}
					}else{
						showProcessList("无故障",Common.NULL, Common.OK);
					}
				}
				else if(Readbuf[1] == 0x62) //读数据
				{
					byte [] v_data = new byte[(Readbuf[0]&0xFF) - 3];
					System.arraycopy(Readbuf, 4, v_data, 0, (Readbuf[0]&0xFF) - 3);
					String v_show = "";
					String v_get = "";
					String v_get1 = "";
					boolean isver = false;
					int v_code = (Readbuf[2]&0xFF) * 0x100 + (Readbuf[3]&0xFF);
					switch(v_code)
					{
						case 0xF190:
							v_show = new String(v_data);
							v_get = new String(cartype.vin);
							break;
						case 0xF187:
						case 0xF19E:
						case 0xF013:
							v_show = new String(v_data);
							v_get = CommonXml.GetEcuInfoSn(cartype.mesinfo, v_module);
							isver =true;
							break;
						case 0xF191:   //hard version
						case 0xF192:
						case 0xF193:
							v_show = new String(v_data);
							v_get = CommonXml.GetEcuInfoHard(cartype.mesinfo, v_module);
							//v_get1 = CommonXml.GetEcuInfoHard(cartype.mesinfo, v_module,1);
							isver =true;
							break;
						case 0xF194:   //soft version
						case 0xF195:
						case 0xF188:
							v_show = new String(v_data);
							if(v_module.equals("GBC") && v_code == 0xF194)
							{
								v_get = CommonXml.GetEcuInfoHard(cartype.mesinfo, v_module);
								//v_get1 = CommonXml.GetEcuInfoHard(cartype.mesinfo, v_module,1);
							}
							else
							{
								v_get = CommonXml.GetEcuInfoSoft(cartype.mesinfo, v_module);
								//v_get1 = CommonXml.GetEcuInfoSoft(cartype.mesinfo, v_module,1);
							}
							isver =true;
							break;
						case 0xD009:  //配置码
						case 0x3011:
						case 0x7601:
						case 0x3801:
						case 0x7407:
							int adrpos = 0;
							if("AMP".equals(v_module))
								adrpos = 116;
							else if("IHU".equals(v_module))
								adrpos = 66;
							else if("RFR".equals(v_module))
								adrpos = 127;
							else if("TBOX".equals(v_module))
								adrpos = 36;
							else if("CLM".equals(v_module))
								adrpos = 98;
							v_show = Commonfunc.bytesToHexString(v_data, 0, v_data.length);
							v_get = Commonfunc.bytesToHexString(cartype.byteConfig,adrpos,adrpos + v_data.length);
							v_get1 = "config";
							break;
						case 0x5515:  //BTM
						case 0x5514:
						case 0x5511:
						case 0x5512:
						case 0x5513:
							v_show = new String(v_data);
							v_get = "OK";
							break;
					}
					if(v_module.equals("TBOX"))
					{
						v_get1 += "";;
					}
					v_show = v_show.replaceAll(" ", "");
					v_show = v_show.trim();
					if(v_get1.equals("config")) //配置
					{
						if(v_show.equals(v_get))
							showProcessList(v_show,v_get,Common.OK);
						else
							showProcessList(v_show,v_get,Common.NG);
					}
					else if(isver == true)
					{
						if(v_get != null && (v_get.indexOf(v_show) >= 0) && (v_show.length() > 0))
							showProcessList(v_show ,v_get,Common.OK);
						else if(v_get.length() < 2)
						{
							showProcessList(v_show ,"MES:无数据",Common.NULL);
						}
						else
							showProcessList(v_show ,v_get,Common.NG);

					}
					else if(isver == false)
					{
						if(v_show.equals(v_get))
							showProcessList(v_show,v_get,Common.OK);
						else
							showProcessList(v_show,v_get,Common.NG);
					}
					else
						showProcessList(v_show,Common.NULL,Common.NULL);
				}
			}
		}
	}


	private void fun_new_Stand_ReadInfo(Section Pstep)
	{
		int num = Integer.valueOf(Pstep.get("NUM"));
		stepId = Integer.valueOf(Pstep.get("MODULE_ID"));
		int v_req = 0;
		int v_res = 0;
		int v_lastmode = 0;
		String step_t = null;
		//String step_name = null;
		String v_module = null;
		byte [] Readbuf = new byte[512];
		int error = 0;
		int v_len = 0;
		int v_find_k = 0; //K线标致
		byte [] cmdlink = {0x02,0x10,0x03};
		SetCanInitTimer(10);
		for(int i = 1; i < (num + 1); i ++)
		{
			step_t = Pstep.get("T" + i);
			stepName = Pstep.get("T" + i + "_NAME");
			if(stepName == null) continue;
			//获取模块名字
			v_len = stepName.indexOf("-");
			v_find_k = stepName.indexOf("-k");
			if(v_find_k > 0) continue;
			v_module = stepName.substring(0,v_len);
			if(step_t == null) break;
			if(step_t.length() < 3) continue;
			if(step_t.substring(0, 3).equals("CMD"))  //cmd
			{
				//获取cmd长度
				int cmdlen = Commonfunc.hexStringtoInt(step_t.substring(4, 6)) + 1;
				byte [] cmd = new byte[cmdlen];
				if(Commonfunc.CmdStringToBytes(step_t.substring(4), cmd, cmdlen) != cmd.length) return;
				//---------------------发送前处理---------------------
				//确认模块
				v_len = cartype.getMap(v_module);
				if(v_len <= 0) continue;
				//得到CAN ID
				Can can = cartype.getCan(v_module + v_len);   //todo bluetooth
				if(can == null) continue;
				if(can.getMode() != v_lastmode)
				{
					v_lastmode = can.getMode();
					SetCanMode(v_lastmode,can.getBaud());
				}
				if(can != null)
				{
					v_req = can.getSendid();
					v_res = can.getRecvid();
				}
				else
					continue;
				if("TCU".equals(v_module))
				{
					m_com.CanOne2OneUDS(v_req, v_res, cmdlink,cmdlink.length, Readbuf, 5003, 1500, 2);
					Commonfunc.sleep(Common.WAIT_TIME);
				}
				if(cartype.car.equals("CX62") && v_module.equals("TCU") && cmd[1] == 0x22 && (cmd[3]&0xFF) == 0x93)
				{
					int kk = (cartype.byteConfig[2] >>> 5) & 0x07;  // 2-- CVT25;3-- CVT19;4-- 8AT；5--7DCT；6--6DCT
					if(kk == 5 || kk == 7)
						cmd[3] = (byte) 0x91;
				}
				else if(cartype.car.equals("CX62B") && v_module.equals("TCU"))
				{
					int kk = (cartype.byteConfig[2] >>> 5) & 0x07;  // 2-- CVT25;3-- CVT19;4-- 8AT；5--7DCT；6--6DCT
					if(cmd[1] == 0x22 && (cmd[3]&0xFF) == 0x95)
					{
						if(kk == 2)
							cmd[3] = (byte) 0x94;
						else if(kk == 5)
						{
							int ssk = (cartype.byteConfig[23] >>> 3) & 0x07;
							if(ssk == 2)
								cmd[3] = (byte) 0x88;
						}
					}
					else if(cmd[1] == 0x22 && (cmd[3]&0xFF) == 0x91)
					{
						if(kk == 6)
							cmd[3] = (byte) 0x93;
					}
					else if(cmd[1] == 0x22 && (cmd[3]&0xFF) == 0x87)
					{
						int ems = (cartype.byteConfig[6] >>> 4)&0x0F;
						if(kk == 5 && ems == 3)
							cmd[3] = (byte) 0x9E;
					}
				}
				else if(cartype.car.equals("KX63FLB(2.0T)") && v_module.equals("TCU"))
				{
					int kk = (cartype.byteConfig[2] >>> 5) & 0x07;  // 2-- CVT25;3-- CVT19;4-- 8AT；5--7DCT；6--6DCT
					if(cmd[1] == 0x22 && (cmd[3]&0xFF) == 0x87)
					{
						//if(kk == 5)
						//	cmd[3] = (byte) 0x9E;
					}
				}
				//Sleep(10);

				//特殊处理多次发送命令
				if(v_req == 0x760 || v_req == 0x7E2)
				{
					error = m_com.CanOne2OneUDS(v_req, v_res, cmd,cmdlen, Readbuf, 5003, 5000, 2);
				}
				else //普通发送命令
				{
					error = m_com.CanOne2OneUDS(v_req, v_res, cmd,cmdlen, Readbuf, 5003, 1500, 2);
				}
				Commonfunc.sleep(Common.WAIT_TIME);
				//错误处理
				if(error == 5001) //通讯超时
				{
					showProcessList("通讯超时!",Common.NULL,Common.NG);
					continue;
				}
				else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((Readbuf[1]&0xFF) == 0x7F) //异常
					{
						if((Readbuf[3]&0xFF) == 0x31) continue;
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				//特殊处理返回结果
				if(Readbuf[1] == 0x54) //清故障码
				{
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x59) //读故障码
				{
					byte [] dtc = new byte[512];
					ArrayList<HashMap<String,String>> dtclist = new ArrayList<HashMap<String,String>>();

					dtc[0] = (byte) (((Readbuf[0]&0xFF) - 3) / 4);
					System.arraycopy(Readbuf, 4, dtc, 1, (dtc[0]&0xFF) * 4);
					dtclist = FileReader.readDtc(v_module + v_len, dtc, 3, false, false);
					//&&((Readbuf[7]>>0) & 0x01)==0x01
					if(dtclist.size() > 0){
						for(int z = 0; z < dtclist.size(); z ++){
							showProcessList(dtclist.get(z).get(Common.CONTENT),Common.NULL, Common.NG);
							mDtc.add(v_module + "--" + dtclist.get(z).get(Common.CONTENT));
						}
					}else{
						showProcessList("无故障",Common.NULL, Common.OK);
					}
				}
				else if(Readbuf[1] == 0x62) //读数据
				{
					byte [] v_data = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf, 4, v_data, 0, Readbuf[0] - 3);
					String v_show = "";
					String v_get = "";
					String v_get1 = "";
					boolean isver = false;
					int v_code = (Readbuf[2]&0xFF) * 0x100 + (Readbuf[3]&0xFF);
					switch(v_code)
					{
						case 0xF190:
							v_show = new String(v_data);
							v_get = new String(cartype.vin);
							break;
						case 0xF187:
						case 0xF19E:
							v_show = new String(v_data);
							v_get = CommonXml.GetEcuInfoSn(cartype.mesinfo, v_module);
							isver =true;
							break;
						case 0xF191:   //hard version
						case 0xF192:
						case 0xF193:
							v_show = new String(v_data);
							v_get = CommonXml.GetEcuInfoHard(cartype.mesinfo, v_module);
							//v_get1 = CommonXml.GetEcuInfoHard(cartype.mesinfo, v_module,1);
							isver =true;
							break;
						case 0xF194:   //soft version
						case 0xF195:
						case 0xF188:
							v_show = new String(v_data);
							if(v_module.equals("GBC") && v_code == 0xF194)
							{
								v_get = CommonXml.GetEcuInfoHard(cartype.mesinfo, v_module);
								//v_get1 = CommonXml.GetEcuInfoHard(cartype.mesinfo, v_module,1);
							}
							else
							{
								v_get = CommonXml.GetEcuInfoSoft(cartype.mesinfo, v_module);
								//v_get1 = CommonXml.GetEcuInfoSoft(cartype.mesinfo, v_module,1);
							}
							isver =true;
							break;
						case 0xD009:  //配置码
						case 0x3011:
						case 0x7601:
						case 0x3801:
						case 0x7407:
							v_show = Commonfunc.bytesToHexString(v_data, 0, v_data.length);
							v_get = Commonfunc.bytesToHexString(cartype.byteConfig,0,v_data.length);
							v_get1 = "config";
							break;
						case 0x5515:  //BTM
						case 0x5514:
						case 0x5511:
						case 0x5512:
						case 0x5513:
							v_show = new String(v_data);
							v_get = "OK";
							break;
						case 0xF100:
							v_show = new String(v_data);
							isver =true;
							v_get ="";
							break;
					}
					if(v_module.equals("TBOX"))
					{
						v_get1 += "";;
					}
					v_show = v_show.replaceAll(" ", "");
					v_show = v_show.trim();
					if(v_get1.equals("config")) //配置
					{
						if(v_show.equals(v_get))
							showProcessList(v_show,v_get,Common.OK);
						else
							showProcessList(v_show ,v_get,Common.NG);
					}
					else if(isver == true)
					{
						if(v_get != null && (v_get.indexOf(v_show) >= 0) && (v_show.length() > 0))
							showProcessList(v_show ,v_get,Common.OK);
						else if(v_get.length() < 2)
						{
							showProcessList(v_show ,"MES:无数据",Common.NULL);
						}
						else
							showProcessList(v_show ,v_get,Common.NG);

					}
					else if(isver == false)
					{
						if(v_show.equals(v_get))
							showProcessList(v_show,v_get,Common.OK);
						else
							showProcessList(v_show,v_get,Common.NG);
					}
					else
						showProcessList(v_show,Common.NULL,Common.NULL);
				}
			}
		}
	}

	private void fun_new_Stand_OBD(Section Pstep)
	{
		int num = Integer.valueOf(Pstep.get("NUM"));
		//int step_id = Integer.valueOf(Pstep.get("MODULE_ID"));
		int v_req = 0x7DF;
		int v_res = 0x7E8;
		String step_t = null;
		byte [] Readbuf = new byte[512];
		String v_show = "";
		int error = 0;
		SetCanInitTimer(15);
		byte [] v_autocmd = {0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
		SetStandCanAutoFrame(0x7E0,v_autocmd);
		boolean vinError = false;
		String vin="";
		String obd="";
		int obd_num = 0;
		String odo="3";
		String emsModuleId="";
		String emsName="";
		String ems_calId1="";
		String ems_calId2="";
		String ems_calId3="";
		String ems_cvn1="";
		String ems_cvn2="";
		String ems_cvn3="";
		String tcuModuleId="";
		String tcuName="";
		String tcu_calId1="";
		String tcu_calId2="";
		String tcu_calId3="";
		String tcu_cvn1="";
		String tcu_cvn2="";
		String tcu_cvn3="";
		String opass="";
		emsModuleId = String.format("%02X", v_req)+"/"+String.format("%02X", v_res);
		SetCanMode(1,500000);

		for(int i = 1; i < (num + 1); i ++)
		{
			step_t = Pstep.get("T" + i);
			if(step_t == null) break;
			stepName = Pstep.get("T" + i + "_NAME");
			if(stepName == null) break;
			if(step_t.length() < 3) continue;
			if(step_t.substring(0, 3).equals("CMD"))  //cmd
			{
				//获取cmd长度
				int cmdlen = Commonfunc.hexStringtoInt(step_t.substring(4, 6)) + 1;
				byte [] cmd = new byte[cmdlen];
				if(Commonfunc.CmdStringToBytes(step_t.substring(4), cmd, cmdlen) != cmd.length) return;
				//---------------------发送前处理---------------------
				if(i == 7)
				{
					v_req = 0x7E1;
					v_res = 0x7E9;
					SetStandCanAutoFrame(0,v_autocmd);
					int v_len = cartype.getMap("TCU");
					if(v_len <= 0) break;
					tcuModuleId = String.format("%02X", v_req)+"/"+String.format("%02X", v_res);
				}


				//特殊处理多次发送命令
				if(false) //广播
				{
					//error = bluetooth.CanSendOneOnly(0x7DF, cmd, cmd.length);
				}
				else //普通发送命令
				{
					error = m_com.CanOne2OneUDS(v_req, v_res, cmd,cmdlen, Readbuf, 5003, Common.CMD_MAX_TIME, 3);
				}
				Commonfunc.sleep(Common.WAIT_TIME);
				//错误处理
				if(error == 5001) //通讯超时
				{
					vinError=true;
					showProcessList("通讯超时!",Common.NULL,Common.NG);
					break;
				}
				else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
					return;
				}
				else if(error < 100) //异常回复
				{
					if((Readbuf[1]&0xFF) == 0x7F) //异常
					{
						if(i > 6 )
						{
							if(obd_num < 0x29)
								continue;
						}
						vinError=true;
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				//特殊处理返回结果
				if(Readbuf[1] == 0x49) //EMS读数据
				{
					byte [] v_data = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf, 4, v_data, 0, Readbuf[0] - 3);
					String v_get = "";
					int v_code = (Readbuf[2]&0xFF);
					switch(v_code)
					{
						case 0x02:  //vin
							v_show = new String(v_data);
							vin = v_show;
							v_get = new String(cartype.vin);
							break;
						case 0x0A: //ECU name
							v_show = new String(v_data);
							v_show = v_show.trim();
							v_get = "";
							if(i < 7){
								emsName= v_show;
							}else{
								tcuName= v_show;
							}
							break;
						case 0x04://读取CAL ID
							v_show = new String(v_data);
							v_show = v_show.trim();
							v_get = "";
							if(i < 7)
								ems_calId1 = v_show;
							else
								tcu_calId1 = v_show;
							break;
						case 0x06://读取CVN
							v_show = Commonfunc.bytesToHexString(v_data, 0,v_data.length);
							v_show = v_show.trim();
							v_get = "";
							if(i < 7)
								ems_cvn1 = v_show;
							else
								tcu_cvn1 = v_show;
							break;
					}
					if(v_get.length() > 0)
					{
						v_show = v_show.replace(" ", "");
						if(v_show.equals(v_get))
							showProcessList(v_show,v_get,Common.OK);
						else
						{
							vinError=true;
							showProcessList(v_show ,v_get,Common.NG);
						}
					}
					else
						showProcessList(v_show,Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x41)
				{
					v_show = String.format("%02X", Readbuf[3]&0xFF);
					obd_num = Readbuf[3]&0xFF;
					obd=v_show;
					showProcessList(v_show,Common.NULL,Common.OK);
				}
				else
				{
					//showProcessList(step_id + i,step_name, "",Common.Rok);
				}
			}
		}
		SetStandCanAutoFrame(0,v_autocmd);
		if(vinError){//读出来的和扫描的不一致就不上传
			showProcessList("OBD数据解析失败",Common.NULL,Common.NG);
			return;
		}
		if("".equals(obd)||"".equals(odo)||"".equals(emsName)||"".equals(ems_calId1)||"".equals(ems_cvn1)){
			opass="0";
		}else if(cartype.getMap("TCU")>0&&("".equals(tcuName)||"".equals(tcu_calId1)||"".equals(tcu_cvn1))){
			opass="0";
		}else{
			opass="1";
		}
		String date=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
		String param="<root><vin>"+vin+"</vin><Type>01</Type><Result>ok</Result><OBDDataDetail><EMS><obd_VIN>"+
				vin+"</obd_VIN><obd>"+obd+"</obd><odo>"+odo+"</odo><moduleID>"+emsModuleId+"</moduleID><ECUname>"+
				emsName+"</ECUname><calID_01>"+ems_calId1+"</calID_01><calID_02>"+ems_calId2+"</calID_02><calID_03>"+
				ems_calId3+"</calID_03><cvn_01>"+ems_cvn1+"</cvn_01><cvn_02>"+ems_cvn2+"</cvn_02><cvn_03>"+
				ems_cvn3+"</cvn_03></EMS><TCU><moduleID>"+tcuModuleId+"</moduleID><ECUname>"+
				tcuName+"</ECUname><calID_01>"+tcu_calId1+"</calID_01><calID_02>"+tcu_calId2+"</calID_02><calID_03>"+
				tcu_calId3+"</calID_03><cvn_01>"+tcu_cvn1+"</cvn_01><cvn_02>"+tcu_cvn2+"</cvn_02><cvn_03>"+
				tcu_cvn3+"</cvn_03></TCU><opass>"+opass+"</opass><otestdate>"+date+"</otestdate><O_created_author>CP8</O_created_author>"+
				"<O_CarManuf>SYC-CB</O_CarManuf><O_Operation>CP8</O_Operation><O_Operator>CP8</O_Operator></OBDDataDetail></root>";


		byte[] nul={0};//替换00乱码
		if(param.contains(new String(nul))){
			param=param.replace(new String(nul), "");
		}
		boolean isupok = false;
		m_com.saveLogData(0,param);
		for(int kk = 0; kk < 3; kk ++)
		{
			String result=HttpRequest.uploadOBDToMes(param);
			stepName = "上传OBD数据";
			//打印LOG
			m_com.saveLogData(0,result);
			if(result!=null&&result.contains("成功")){
				showProcessList("上传OBD成功",Common.NULL,Common.OK);
				isupok = true;
				break;
			}else{
				showTip("上传重试第" + (kk + 1) + "次...");
			}
		}
		if(isupok == false)
			showProcessList("上传OBD失败",Common.NULL,Common.NG);
		//上传OBD数据2
		String obd2="{\"root\":{\"vin\":\""+vin+"\",\"Type\":\"01\",\"Result\":\"ok\",\"OBDDataDetail\":{\"EMS\":{\"obd_VIN\":\""+
				vin+"\",\"obd\":\""+obd+"\",\"odo\":\""+odo+"\",\"moduleID\":\""+emsModuleId+"\",\"ECUname\":\""+
				emsName+"\",\"calID_01\":\""+ems_calId1+"\",\"calID_02\":\""+ems_calId2+"\",\"calID_03\":\""+
				ems_calId3+"\",\"cvn_01\":\""+ems_cvn1+"\",\"cvn_02\":\""+ems_cvn2+"\",\"cvn_03\":\""+
				ems_cvn3+"\"},\"TCU\":{\"moduleID\":\""+tcuModuleId+"\",\"ECUname\":\""+
				tcuName+"\",\"calID_01\":\""+tcu_calId1+"\",\"calID_02\":\""+tcu_calId2+"\",\"calID_03\":\""+
				tcu_calId3+"\",\"cvn_01\":\""+tcu_cvn1+"\",\"cvn_02\":\""+tcu_cvn2+"\",\"cvn_03\":\""+
				tcu_cvn3+"\"},\"opass\":\""+opass+"\",\"otestdate\":\""+date+"\",\"O_created_author\":\"CP8\","+
				"\"O_CarManuf\":\"SYC-CB\",\"O_Operation\":\"CP8\",\"O_Operator\":\"CP8\"}}}";
		if(Common.mes_obd2_en == 1)
		{
			isupok = false;
			m_com.saveLogData(0,"Up OBD2 address:" + Common.mes_obd2);
			m_com.saveLogData(0,"Up OBD2 data:" + obd2);
			for(int kk = 0; kk < 3; kk ++)
			{
				String result=HttpRequest.sendRequestPost(Common.mes_obd2,obd2);
				m_com.saveLogData(0,"Up OBD2 data:" + result);
				stepName = "上传OBD地址2数据";
				if(result!=null&&result.contains("成功")){
					showProcessList("上传OBD地址2成功",Common.NULL,Common.OK);
					isupok = true;
					break;
				}else{
					showTip("上传重试第" + (kk + 1) + "次...");
				}
			}
			if(isupok == false)
				showProcessList("上传OBD地址2失败",Common.NULL,Common.NG);
		}
	}

	private void fun_T1N_Stand_OBD(Section Pstep)
	{
		int num = Integer.valueOf(Pstep.get("NUM"));
		//int step_id = Integer.valueOf(Pstep.get("MODULE_ID"));
		int v_req = 0x7DF;
		int v_res = 0x7E8;
		String step_t = null;
		byte [] Readbuf = new byte[512];
		String v_show = "";
		int error = 0;
		SetCanInitTimer(15);
		byte [] v_autocmd = {0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
		SetStandCanAutoFrame(0x7E0,v_autocmd);
		boolean vinError = false;
		String vin="";
		String obd="";
		int obd_num = 0;
		String odo="3";
		String emsModuleId="";
		String emsName="";
		String ems_calId1="";
		String ems_calId2="";
		String ems_calId3="";
		String ems_cvn1="";
		String ems_cvn2="";
		String ems_cvn3="";
		String tcuModuleId="";
		String tcuName="";
		String tcu_calId1="";
		String tcu_calId2="";
		String tcu_calId3="";
		String tcu_cvn1="";
		String tcu_cvn2="";
		String tcu_cvn3="";
		String BSGModuleId="";
		String BSGName="";
		String BSG_calId1="";
		String BSG_calId2="";
		String BSG_calId3="";
		String BSG_cvn1="";
		String BSG_cvn2="";
		String BSG_cvn3="";
		String BMSModuleId="";
		String BMSName="";
		String BMS_calId1="";
		String BMS_calId2="";
		String BMS_calId3="";
		String BMS_cvn1="";
		String BMS_cvn2="";
		String BMS_cvn3="";
		String HCUModuleId="";
		String HCUName="";
		String HCU_calId1="";
		String HCU_calId2="";
		String HCU_calId3="";
		String HCU_cvn1="";
		String HCU_cvn2="";
		String HCU_cvn3="";
		String opass="";

		emsModuleId = String.format("%02X", v_req)+"/"+String.format("%02X", v_res);
		SetCanMode(1,500000);
		for(int i = 1; i < (num + 1); i ++)
		{
			step_t = Pstep.get("T" + i);
			if(step_t == null) break;
			stepName = Pstep.get("T" + i + "_NAME");
			if(stepName == null) break;
			if(step_t.length() < 3) continue;
			if(step_t.substring(0, 3).equals("CMD"))  //cmd
			{
				//获取cmd长度
				int cmdlen = Commonfunc.hexStringtoInt(step_t.substring(4, 6)) + 1;
				byte [] cmd = new byte[cmdlen];
				if(Commonfunc.CmdStringToBytes(step_t.substring(4), cmd, cmdlen) != cmd.length) return;
				//---------------------发送前处理---------------------
				if(i == 7)
				{
					v_req = 0x7E1;
					v_res = 0x7E9;
					SetStandCanAutoFrame(0,v_autocmd);
					int v_len = cartype.getMap("TCU");
					if(v_len <= 0) {
						i=9;
						continue;
					}
					tcuModuleId = String.format("%02X", v_req)+"/"+String.format("%02X", v_res);
				}else if (i==10){
					v_req = 0x7E3;
					v_res = 0x7EB;
					SetStandCanAutoFrame(0,v_autocmd);
					int v_len = cartype.getMap("BSG");
					if(v_len <= 0) {
						i=12;
						continue;
					}
					BSGModuleId = String.format("%02X", v_req)+"/"+String.format("%02X", v_res);
				}else if (i==13){
					v_req = 0x7E5;
					v_res = 0x7ED;
					SetStandCanAutoFrame(0,v_autocmd);
					int v_len = cartype.getMap("BMS");
					if(v_len <= 0) {
						i=15;
						continue;
					}
					BMSModuleId = String.format("%02X", v_req)+"/"+String.format("%02X", v_res);
				}else if (i==16){
					v_req = 0x7E2;
					v_res = 0x7EA;
					SetStandCanAutoFrame(0,v_autocmd);
					int v_len = cartype.getMap("HCU");
					if(v_len <= 0) {
						break;
					}
					HCUModuleId = String.format("%02X", v_req)+"/"+String.format("%02X", v_res);
				}


				//特殊处理多次发送命令
				if(false) //广播
				{
					//error = bluetooth.CanSendOneOnly(0x7DF, cmd, cmd.length);
				}
				else //普通发送命令
				{
					error = m_com.CanOne2OneUDS(v_req, v_res, cmd,cmdlen, Readbuf, 5003, Common.CMD_MAX_TIME, 3);
				}
				Commonfunc.sleep(Common.WAIT_TIME);
				//错误处理
				if(error == 5001) //通讯超时
				{
					vinError=true;
					showProcessList("通讯超时!",Common.NULL,Common.NG);
					break;
				}
				else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
					return;
				}
				else if(error < 100) //异常回复
				{
					if((Readbuf[1]&0xFF) == 0x7F) //异常
					{
						if(i > 6 )
						{
							if(obd_num < 0x29)
								continue;
						}
						vinError=true;
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				//特殊处理返回结果
				if(Readbuf[1] == 0x49) //EMS读数据
				{
					byte [] v_data = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf, 4, v_data, 0, Readbuf[0] - 3);
					String v_get = "";
					int v_code = (Readbuf[2]&0xFF);
					switch(v_code)
					{
						case 0x02:  //vin
							v_show = new String(v_data);
							vin = v_show;
							v_get = new String(cartype.vin);
							break;
						case 0x0A: //ECU name
							v_show = new String(v_data);
							v_show = v_show.trim();
							v_get = "";
							if(i == 4){
								emsName= v_show;
							}else if (i==7){
								tcuName= v_show;
							}else if (i==10){
								BSGName= v_show;
							}else if (i==13){
								BMSName= v_show;
							}else if (i==16){
								HCUName= v_show;
							}
							break;
						case 0x04://读取CAL ID
							v_show = new String(v_data);
							v_show = v_show.trim();
							v_get = "";
							if(i == 5)
								ems_calId1 = v_show;
							else if (i==8)
								tcu_calId1 = v_show;
							else if (i==11)
								BSG_calId1 = v_show;
							else if (i==14)
								BMS_calId1 = v_show;
							else if (i==17)
								HCU_calId1 = v_show;
							break;
						case 0x06://读取CVN
							v_show = Commonfunc.bytesToHexString(v_data, 0,v_data.length);
							v_show = v_show.trim();
							v_get = "";
							if(i == 6)
								ems_cvn1 = v_show;
							else if (i==9)
								tcu_cvn1 = v_show;
							else if (i==12)
								BSG_cvn1 = v_show;
							else if (i==15)
								BMS_cvn1 = v_show;
							else if (i==18)
								HCU_cvn1 = v_show;
							break;
					}
					if(v_get.length() > 0)
					{
						v_show = v_show.replace(" ", "");
						if(v_show.equals(v_get))
							showProcessList(v_show,v_get,Common.OK);
						else
						{
							vinError=true;
							showProcessList(v_show ,v_get,Common.NG);
						}
					}
					else
						showProcessList(v_show,Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x41)
				{
					byte [] v_data = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf, 4, v_data, 0, Readbuf[0] - 3);
					if (Readbuf[2]== 0x1C) {
						v_show = String.format("%02X", Readbuf[3] & 0xFF);
						obd_num = Readbuf[3] & 0xFF;
						obd = v_show;
						showProcessList(v_show,Common.NULL, Common.OK);
					}else{
						double odo_num=(v_data[3]&0xFF+((v_data[2]&0xFF)*0x100)+((v_data[1]&0xFF)*0x10000)+((v_data[0]&0xFF)*0x1000000))*0.1;
						odo = odo_num+"km";
						v_show=odo;
						showProcessList(v_show,Common.NULL, Common.OK);
					}
				}
				else
				{
					//showProcessList(step_id + i,step_name, "",Common.Rok);
				}
			}
		}
		SetStandCanAutoFrame(0,v_autocmd);
		if(vinError){//读出来的和扫描的不一致就不上传
			showProcessList("OBD数据解析失败",Common.NULL,Common.NG);
			return;
		}
		if(("".equals(obd)||"".equals(odo)||"".equals(emsName)||"".equals(ems_calId1)||"".equals(ems_cvn1))
				&&(cartype.getMap("TCU")>0&&("".equals(tcuName)||"".equals(tcu_calId1)||"".equals(tcu_cvn1)))
				&&(cartype.getMap("BSG")>0&&("".equals(BSGName)||"".equals(BSG_calId1)||"".equals(BSG_cvn1)))
				&&(cartype.getMap("BMS")>0&&("".equals(BMSName)||"".equals(BMS_calId1)||"".equals(BMS_cvn1)))
				&&(cartype.getMap("HCU")>0&&("".equals(HCUName)||"".equals(HCU_calId1)||"".equals(HCU_cvn1)))
		){
			opass="0";
		}
		else{
			opass="1";
		}
		String date=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());

		//TODO
		String param="<root><vin>"+vin+"</vin><Type>01</Type><Result>ok</Result><OBDDataDetail><EMS><obd_VIN>"+
				vin+"</obd_VIN><obd>"+obd+"</obd><odo>"+odo+"</odo><moduleID>"+emsModuleId+"</moduleID><ECUname>"+
				emsName+"</ECUname><calID_01>"+ems_calId1+"</calID_01><calID_02>"+ems_calId2+"</calID_02><calID_03>"+
				ems_calId3+"</calID_03><cvn_01>"+ems_cvn1+"</cvn_01><cvn_02>"+ems_cvn2+"</cvn_02><cvn_03>"+
				ems_cvn3+"</cvn_03></EMS>";
		if (cartype.getMap("TCU")>0){
			param=param+"<TCU><moduleID>"+tcuModuleId+"</moduleID><ECUname>"+
					tcuName+"</ECUname><calID_01>"+tcu_calId1+"</calID_01><calID_02>"+tcu_calId2+"</calID_02><calID_03>"+
					tcu_calId3+"</calID_03><cvn_01>"+tcu_cvn1+"</cvn_01><cvn_02>"+tcu_cvn2+"</cvn_02><cvn_03>"+
					tcu_cvn3+"</cvn_03></TCU>";
		}
		if (cartype.getMap("BSG")>0){
			param=param+"<BSG><moduleID>"+BSGModuleId+"</moduleID><ECUname>"+
					BSGName+"</ECUname><calID_01>"+BSG_calId1+"</calID_01><calID_02>"+BSG_calId2+"</calID_02><calID_03>"+
					BSG_calId3+"</calID_03><cvn_01>"+BSG_cvn1+"</cvn_01><cvn_02>"+BSG_cvn2+"</cvn_02><cvn_03>"+
					BSG_cvn3+"</cvn_03></BSG>";
		}
		if (cartype.getMap("BMS")>0){
			param=param+"<BMS><moduleID>"+BMSModuleId+"</moduleID><ECUname>"+
					BMSName+"</ECUname><calID_01>"+BMS_calId1+"</calID_01><calID_02>"+BMS_calId2+"</calID_02><calID_03>"+
					BMS_calId3+"</calID_03><cvn_01>"+BMS_cvn1+"</cvn_01><cvn_02>"+BMS_cvn2+"</cvn_02><cvn_03>"+
					BMS_cvn3+"</cvn_03></BMS>";
		}
		if (cartype.getMap("HCU")>0){
			param=param+"<HCU><moduleID>"+HCUModuleId+"</moduleID><ECUname>"+
					HCUName+"</ECUname><calID_01>"+HCU_calId1+"</calID_01><calID_02>"+HCU_calId2+"</calID_02><calID_03>"+
					HCU_calId3+"</calID_03><cvn_01>"+HCU_cvn1+"</cvn_01><cvn_02>"+HCU_cvn2+"</cvn_02><cvn_03>"+
					HCU_cvn3+"</cvn_03></HCU>";
		}
		param=param+"<opass>"+opass+"</opass><otestdate>"+date+"</otestdate><O_created_author>CP8</O_created_author>"+
				"<O_CarManuf>SYC-CB</O_CarManuf><O_Operation>CP8</O_Operation><O_Operator>CP8</O_Operator></OBDDataDetail></root>";


		byte[] nul={0};//替换00乱码
		if(param.contains(new String(nul))){
			param=param.replace(new String(nul), "");
		}
		boolean isupok = false;
		m_com.saveLogData(0,param);
		for(int kk = 0; kk < 3; kk ++)
		{
			String result=HttpRequest.uploadOBDToMes(param);
			stepName = "上传OBD数据";
			//打印LOG
			m_com.saveLogData(0,result);
			if(result!=null&&result.contains("成功")){
				showProcessList("上传OBD成功",Common.NULL,Common.OK);
				isupok = true;
				break;
			}else{
				showTip("上传重试第" + (kk + 1) + "次...");
			}
		}
		if(isupok == false)
			showProcessList("上传OBD失败",Common.NULL,Common.NG);
		String obd2="{\"root\":{\"vin\":\""+vin+"\",\"Type\":\"01\",\"Result\":\"ok\",\"OBDDataDetail\":{\"EMS\":{\"obd_VIN\":\""+
				vin+"\",\"obd\":\""+obd+"\",\"odo\":\""+odo+"\",\"moduleID\":\""+emsModuleId+"\",\"ECUname\":\""+
				emsName+"\",\"calID_01\":\""+ems_calId1+"\",\"calID_02\":\""+ems_calId2+"\",\"calID_03\":\""+
				ems_calId3+"\",\"cvn_01\":\""+ems_cvn1+"\",\"cvn_02\":\""+ems_cvn2+"\",\"cvn_03\":\""+
				ems_cvn3+"\"},";
		if (cartype.getMap("TCU")>0){
			obd2=obd2+	"\"TCU\":{\"moduleID\":\""+tcuModuleId+"\",\"ECUname\":\""+
					tcuName+"\",\"calID_01\":\""+tcu_calId1+"\",\"calID_02\":\""+tcu_calId2+"\",\"calID_03\":\""+
					tcu_calId3+"\",\"cvn_01\":\""+tcu_cvn1+"\",\"cvn_02\":\""+tcu_cvn2+"\",\"cvn_03\":\""+
					tcu_cvn3+"\"},";
		}
		if (cartype.getMap("BSG")>0){
			obd2=obd2+	"\"BSG\":{\"moduleID\":\""+BSGModuleId+"\",\"ECUname\":\""+
					BSGName+"\",\"calID_01\":\""+BSG_calId1+"\",\"calID_02\":\""+BSG_calId2+"\",\"calID_03\":\""+
					BSG_calId3+"\",\"cvn_01\":\""+BSG_cvn1+"\",\"cvn_02\":\""+BSG_cvn2+"\",\"cvn_03\":\""+
					BSG_cvn3+"\"},";
		}
		if (cartype.getMap("BMS")>0){
			obd2=obd2+	"\"BMS\":{\"moduleID\":\""+BMSModuleId+"\",\"ECUname\":\""+
					BMSName+"\",\"calID_01\":\""+BMS_calId1+"\",\"calID_02\":\""+BMS_calId2+"\",\"calID_03\":\""+
					BMS_calId3+"\",\"cvn_01\":\""+BMS_cvn1+"\",\"cvn_02\":\""+BMS_cvn2+"\",\"cvn_03\":\""+
					BMS_cvn3+"\"},";
		}
		if (cartype.getMap("HCU")>0){
			obd2=obd2+	"\"HCU\":{\"moduleID\":\""+HCUModuleId+"\",\"ECUname\":\""+
					HCUName+"\",\"calID_01\":\""+HCU_calId1+"\",\"calID_02\":\""+HCU_calId2+"\",\"calID_03\":\""+
					HCU_calId3+"\",\"cvn_01\":\""+HCU_cvn1+"\",\"cvn_02\":\""+HCU_cvn2+"\",\"cvn_03\":\""+
					HCU_cvn3+"\"},";
		}

		obd2=obd2+"\"opass\":\""+opass+"\",\"otestdate\":\""+date+"\",\"O_created_author\":\"CP8\","+
				"\"O_CarManuf\":\"SYC-CB\",\"O_Operation\":\"CP8\",\"O_Operator\":\"CP8\"}}}";


		if(Common.mes_obd2_en == 1)
		{
			isupok = false;
			m_com.saveLogData(0,"Up OBD2 address:" + Common.mes_obd2);
			m_com.saveLogData(0,"Up OBD2 data:" + obd2);
			for(int kk = 0; kk < 3; kk ++)
			{
				String result=HttpRequest.sendRequestPost(Common.mes_obd2,obd2);
				m_com.saveLogData(0,"Up OBD2 data:" + result);
				stepName = "上传OBD地址2数据";
				if(result!=null&&result.contains("成功")){
					showProcessList("上传OBD地址2成功",Common.NULL,Common.OK);
					isupok = true;
					break;
				}else{
					showTip("上传重试第" + (kk + 1) + "次...");
				}
			}
			if(isupok == false)
				showProcessList("上传OBD地址2失败",Common.NULL,Common.NG);
		}
	}

	//单个模块
	private void fun_new_Stand_module(Section Pstep)
	{
		int num = Integer.valueOf(Pstep.get("NUM"));
		int step_id = Integer.valueOf(Pstep.get("MODULE_ID"));
		int v_req = 0;
		int v_res = 0;
		String step_t = null;
		String step_name = null;
		String v_module = null;
		byte [] Readbuf = new byte[512];
		int error = 0;
		int v_len = 0;
		int v_find_k = 0; //K线标致
		SetCanInitTimer(10);
		for(int i = 1; i < (num + 1); i ++)
		{
			step_t = Pstep.get("T" + i);
			step_name = Pstep.get("T" + i + "_NAME");
			//获取模块名字
			v_len = step_name.indexOf("-");
			v_find_k = step_name.indexOf("-k");
			v_module = step_name.substring(0,v_len);
			if(step_t == null) break;
			if(step_t.length() < 3) continue;
			if(step_t.substring(0, 3).equals("CMD"))  //cmd
			{
				//获取cmd长度
				int cmdlen = Commonfunc.hexStringtoInt(step_t.substring(4, 6)) + 1;
				byte [] cmd = new byte[cmdlen];
				if(Commonfunc.CmdStringToBytes(step_t.substring(4), cmd, cmdlen) != cmd.length) return;
				//---------------------发送前处理---------------------
				//确认模块
				v_len = cartype.getMap(v_module);
				if(v_len <= 0) continue;
				//得到CAN ID
				v_module = v_module + v_len;
				v_req = cartype.getCan(v_module + v_len).getSendid();
				v_res = cartype.getCan(v_module + v_len).getRecvid();
				//Sleep(10);

				//特殊处理多次发送命令
				if(i == -1)
				{
				}
				else //普通发送命令
				{
					error = m_com.CanOne2OneUDS(v_req, v_res, cmd,cmdlen, Readbuf, 5003, Common.CMD_MAX_TIME, 3);
				}
				Commonfunc.sleep(Common.WAIT_TIME);
				//错误处理
				if(error == 5001) //通讯超时
				{
					showProcessList("通讯超时!",Common.NULL,Common.NG);
					continue;
				}
				else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((Readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				//特殊处理返回结果
				if(Readbuf[1] == 0x54) //清故障码
				{
					showProcessList(step_name,Common.NULL,Common.NG);
				}
				else if(Readbuf[1] == 0x59) //读故障码
				{
					byte [] dtc = new byte[512];
					ArrayList<HashMap<String,String>> dtclist = new ArrayList<HashMap<String,String>>();
					if(i == 2){
						dtc[0] = (byte) (((readbuf[2]&0xFF)-0x80-3)/4);
						for(int k = 0; k < dtc[0]; k ++){
							System.arraycopy(readbuf, 7 + k * 3, dtc, 1 + k * 4, 2);
							dtc[1 + k * 4 + 2] = 0;
							dtc[1 + k * 4 + 3] = readbuf[7 + k * 3 + 2];
						}
						dtclist = FileReader.readDtc(module, dtc, 3, false, false);
					}else{

					}
					dtc[0] = (byte) (((readbuf[0]&0xFF) - 3) / 4);
					System.arraycopy(readbuf, 4, dtc, 1, (dtc[0]&0xFF) * 4);
					dtclist = FileReader.readDtc(module, dtc, 3, false, false);

					if(dtclist.size() > 0){
						for(int z = 0; z < dtclist.size(); z ++){
							showProcessList(dtclist.get(z).get(Common.CONTENT),Common.NULL, Common.NG);
							mDtc.add(module.substring(0, module.length() - 1) + "--" + dtclist.get(z).get(Common.CONTENT));
						}
					}else{
						showProcessList("无故障",Common.NULL, Common.OK);
					}
				}
			}
		}
	}
	private void fun_Stand_CX62C_TCUFlash1(Section Pstep,String Pname)
	{
		int num = Integer.valueOf(Pstep.get("NUM"));
		int Pid = Integer.valueOf(Pstep.get("MODULE_ID"));
		String Pmodule = Pstep.get("MODULE");
		stepId = Pid;
		//stepId = Pid;
		String step_t = null;
		//String step_name = null;
		byte [] Readbuf = new byte[512];
		byte [] seed = new byte[4];
		byte [] key = new byte[4];
		int v_maxlen = 0;
		if (Common.Communication==0) {
			if(!SetCanInitial(Pmodule,canid)) {
				showProcessList("设置通讯盒",Common.NULL, Common.NG);
				return;
			}
			SetCanInitTimer(0);
			SetCanMode(1,500000);
		}else {
			if(!m_com.SetCanBaud(500000))
			{
				showProcessList("设置波特率",Common.NULL,Common.NG);
				return;
			}
			if(!m_com.SetCanMode(2))
			{
				showProcessList("设置CanMode",Common.NULL,Common.NG);
				return;
			}
			if(!m_com.SetCommunTimer(5, 1000, 5000, 0))
			{
				showProcessList("设置时序",Common.NULL,Common.NG);
				return;
			}
		}
		Can can = cartype.getCan(Pstep.get("MODULE"));
		canid[0] = can.getSendid();
		canid[1] = can.getRecvid();
		//先解析刷写数据
		String v_dri_file = "";
		byte [] appbuf = null;
		//int v_applen = 0;
		byte [] dribuf = null;
		//int v_drilen = 0;
		byte [] v_dri_adr = new byte[64];
		byte [] v_dri_len = new byte[4];
		int v_drilength = 0;
		int v_dri_down = 0;
		byte [] v_app_adr = new byte[64];
		byte [] v_app_len = new byte[4];
		int v_applength = 0;
		int v_app_down = 0;
		int v_down_block = 0; //已经下载的块数
		//String tcu_drive = "132000028_100_0.1.0";
		//String tcu_name = "F20-3621010_002_00.04.02";
		String tcu_drive = Pstep.get("DRIVE_NAME");
		String tcu_name =  "";
		if(tcu_drive == null || tcu_drive.length() < 5)
		{
			tcu_drive = "132000028_100_0.1.0";
		}
		if(tcu_name == null || tcu_name.length() < 5)
		{
			tcu_name = CommonXml.GetEcuFlashName(cartype.mesinfo, "TCU_FLASH");
		}
		if(tcu_name == null || tcu_name.length() < 5)
		{
			tcu_name =  Pstep.get("TCU_NAME");
		}
		byte [] v_crc = null;
		//String v_app_file = cartype.carDirectory +  "TCU/F20-3621010_002_00.06.01/";
		String v_app_file = Common.FLASH+  "TCU/" + tcu_name + "/";
		m_com.m_log.PrintAppend("TCU FIle:" +  v_app_file );

		byte [] cmd_link = {0x02,0x3e,(byte) 0x80};
		int error = 0;
		for(int i = 1; i < (num + 1); i ++)
		{
			stepId = Pid + i;
			step_t = Pstep.get("T" + i);
			stepName = Pstep.get("T" + i + "_NAME");
			if(step_t == null) break;
			if(step_t.length() < 3) continue;
			if(step_t.substring(0, 3).equals("CMD"))  //cmd
			{
				//获取cmd长度
				int cmdlen = Commonfunc.hexStringtoInt(step_t.substring(4, 6)) + 1;
				byte [] cmd = new byte[cmdlen];
				if(Commonfunc.CmdStringToBytes(step_t.substring(4), cmd, cmdlen) != cmd.length) return;
				showTip(stepName + "...");
				//---------------------发送前处理---------------------
				//解析下载文件
				if(i == 4)
				{
					//先解析driver文件
					showTip("解析Driver文件...");
					String v_drivername =  tcu_drive + "_FlashDriver.hex";
					v_dri_file = v_app_file + v_drivername;
					m_com.m_log.PrintAppend("Driver File:" +  v_drivername );
					if((v_drivername != null) && (v_drivername.length() > 5))
					{
						if(".hex".equals(v_drivername.substring(v_drivername.length() - 4)) )
						{
							try {
								dribuf = FileReader.FileReadHexFile(v_dri_file, v_dri_adr);
								System.arraycopy(v_dri_adr, 0, v_dri_len, 0, 4);
								v_drilength =  ((v_dri_adr[0]&0xFF) << 24) + ((v_dri_adr[1]&0xFF) << 16) + ((v_dri_adr[2]&0xFF) << 8) + (v_dri_adr[3]&0xFF);
							} catch (IOException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
								v_drilength = 0;
								showProcessList("打开Driver文件:" + v_dri_file,Common.NULL,Common.NG);
								break;
							}
							if(v_drilength <= 10)
							{
								showProcessList("Driver数据解析",Common.NULL,Common.NG);
								break;
							}
						}
					}
				}
				else if(cmd[1] == 0x27 && cmd[2] == 0x02) //安全认证
				{
					if((seed[0] | seed[1] | seed[2] | seed[3]) == 0) continue;
					//EolFunction.Changan_SafeCode_level(seed,key,0x61E47D07);
					Security.CX62C_TCU_Safekey1(seed, key);
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				}
				else if(cmd[1] == 0x27 && cmd[2] == 0x08) //安全认证
				{
					if((seed[0] | seed[1] | seed[2] | seed[3]) == 0) continue;
					//EolFunction.Changan_SafeCode_level(seed,key,0x61E47D07);
					Security.CX62C_TCU_Safekey4(seed, key);
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				}
				else if(cmd[1] == 0x2E) //写
				{
					int v_code = (cmd[2]&0xFF) * 0x100 + (cmd[3]&0xFF);
					switch(v_code)
					{

					}
				}
				else if(i == 15) //开始下载驱动
				{
					if(v_drilength < 10) //无需下载驱动
					{
						i += 3;
						continue;
					}
					else //下载驱动,驱动暂时按单块处理,FLR也是多块
					{
						System.arraycopy(v_dri_adr, 6, cmd, 4, 4);
						System.arraycopy(v_dri_adr, 10, cmd, 8, 4);
						v_dri_down = 0;
					}
				}
				else if(i == 16) //下载驱动
				{
					byte [] cmd_down = new byte[v_maxlen + 2];
					int v_len = 0;
					int v_start = 0;
					int v_frame = 1;
					while(v_dri_down < v_drilength)
					{
						if((v_dri_down + v_maxlen - 2) >= v_drilength) //last
						{
							v_len = v_drilength - v_dri_down;
						}
						else
						{
							v_len = v_maxlen - 2;
						}
						if((v_len + 2) >= 0x100)
						{
							v_start = 1;
							cmd_down[0] = (byte) ((v_len + 2) / 0x100);
						}
						else
							v_start = 0;
						//拷贝数据
						cmd_down[v_start ++] = (byte) ((v_len + 2) % 0x100);
						cmd_down[v_start ++] = 0x36;
						cmd_down[v_start ++] = (byte)(v_frame ++);
						System.arraycopy(dribuf, v_dri_down, cmd_down, v_start, v_len);

						error = m_com.CanOne2OneUDS(can.getSendid(), can.getRecvid(), cmd_down,v_len+v_start, Readbuf, 5003, Common.CMD_MAX_TIME, 1);
						if((error > 100) || ((Readbuf[1]&0xFF) == 0x7F))//异常
						{
							break;
						}
						Sleep(2);
						m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
						v_dri_down += v_len;
						showTip("下载数据:" + v_drilength + "\\" +  v_dri_down);
					}
				}
				else if(i == 18) //检查有效性CRC
				{
					try {
						v_crc = FileReader.FileReadRsaFile(v_app_file + tcu_drive + "_FlashDriver.rsa");
					} catch (FileNotFoundException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
						break;
					} catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					if(v_crc == null) break;
					int datalen = ((v_crc[0]&0xFF) << 8) + (v_crc[1]&0xFF);
					System.arraycopy(v_crc, 2, cmd, 5, datalen);
				}
				else if(i == 19) //擦除APP,按多个块处理
				{
					//先解析文件
					String appname = v_app_file;
					if(v_down_block == 0)
					{
						appname += tcu_name + "_CAL1.hex";
					}
					else if(v_down_block == 1)
					{
						appname +=  tcu_name + "_ASW1.hex";
					}
					else if(v_down_block == 2)
					{
						appname +=  tcu_name + "_ASW2.hex";
					}
					else if(v_down_block == 3)
					{
						appname +=  tcu_name + "_ASW3.hex";
					}
					else if(v_down_block == 4)
					{
						appname +=  tcu_name + "_ASW4.hex";
					}
					m_com.m_log.PrintAppend("app File:" +  appname );
					if((appname != null) && (appname.length() > 5))
					{
						if(".hex".equals(appname.substring(appname.length() - 4)) )
						{
							try {
								appbuf = FileReader.FileReadHexFile(appname, v_app_adr);
								System.arraycopy(v_app_adr, 0, v_app_len, 0, 4);
								v_applength =  ((v_app_adr[0]&0xFF) << 24) + ((v_app_adr[1]&0xFF) << 16) + ((v_app_adr[2]&0xFF) << 8) + (v_app_adr[3]&0xFF);
							} catch (IOException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
								v_applength = 0;
								showProcessList("打开App文件",Common.NULL,Common.NG);
								break;
							}
							if(appbuf == null) break;
							if(v_applength <= 10)
							{
								showProcessList("App数据解析",Common.NULL,Common.NG);
								break;
							}
						}
					}
					v_app_down = 0;
					System.arraycopy(v_app_adr, 6, cmd, 6, 4);
					System.arraycopy(v_app_len, 0, cmd, 10, 4);
				}
				else if(i == 20) //请求下载APP
				{
					System.arraycopy(v_app_adr, 6, cmd, 4, 4);
					System.arraycopy(v_app_len, 0, cmd, 8, 4);
				}
				else if(i == 21) //下载数据
				{
					byte [] cmd_down = new byte[v_maxlen + 2];
					int v_len = 0;
					int v_start = 0;
					int v_frame = 1;
					while(v_app_down < v_applength)
					{
						if((v_app_down + v_maxlen - 2) >= v_applength) //last
						{
							v_len = v_applength - v_app_down;
						}
						else
						{
							v_len = v_maxlen - 2;
						}
						if((v_len + 2) >= 0x100)
						{
							v_start = 1;
							cmd_down[0] = (byte) ((v_len + 2) / 0x100);
						}
						else
							v_start = 0;
						//拷贝数据
						cmd_down[v_start ++] = (byte) ((v_len + 2) % 0x100);
						cmd_down[v_start ++] = 0x36;
						cmd_down[v_start ++] = (byte)(v_frame ++);
						System.arraycopy(appbuf, v_app_down, cmd_down, v_start, v_len);

						error = m_com.CanOne2OneUDS(can.getSendid(), can.getRecvid(), cmd_down,v_len+v_start, Readbuf, 5003, Common.CMD_MAX_TIME, 1);
						if((error > 100) || ((Readbuf[1]&0xFF) == 0x7F))//异常
						{
							break;
						}
						Sleep(2);
						m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
						v_app_down += v_len;
						showTip("下载数据:" + v_applength + "\\" +  v_app_down);
					}
				}
				else if(i == 23)  //crc
				{
					String crc_file = v_app_file;
					if(v_down_block == 0)
					{
						crc_file +=  tcu_name + "_CAL1.rsa";
					}
					else if(v_down_block == 1)
					{
						crc_file +=  tcu_name + "_ASW1.rsa";
					}
					else if(v_down_block == 2)
					{
						crc_file +=  tcu_name + "_ASW2.rsa";
					}
					else if(v_down_block == 3)
					{
						crc_file +=  tcu_name + "_ASW3.rsa";
					}
					else if(v_down_block == 4)
					{
						crc_file +=  tcu_name + "_ASW4.rsa";
					}
					m_com.m_log.PrintAppend("CRC File:" +  crc_file );
					try {
						v_crc = FileReader.FileReadRsaFile(crc_file);
					} catch (FileNotFoundException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					} catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
						break;
					}
					if(v_crc == null) break;
					int datalen = ((v_crc[0]&0xFF) << 8) + (v_crc[1]&0xFF);
					System.arraycopy(v_crc, 2, cmd, 5, datalen);
				}

				//特殊处理多次发送命令
				if(i == 16 || i == 21)
				{

				}
				else if(i == 8 || i == 9 || i == 10 || i == 26 || i == 27 || i == 28)
				{
					error = m_com.CanSendOneOnly(0x7DF, cmd, cmdlen);
					Sleep(Common.WAIT_TIME);
					continue;
				}
				else //普通发送命令
				{
					error = m_com.CanOne2OneUDS(can.getSendid(), can.getRecvid(), cmd,cmdlen, Readbuf, 5003, Common.CMD_MAX_TIME * 2, 3);
					Sleep(50);
					m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
				}
				Sleep(Common.WAIT_TIME);
				//错误处理
				if(error == 5001) //通讯超时
				{
					if(i > 3)
					{
						showProcessList("通讯超时!",Common.NULL,Common.NG);
						break;
					}
					else
						continue;
				}
				else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					if(i > 3)
					{
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
						return;
					}
					else
						continue;
				}
				else if(error < 100) //异常回复
				{
					if((Readbuf[1]&0xFF) == 0x7F) //异常
					{
						if(i > 6)
						{
							showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
							break;
						}
						else
							continue;
					}
				}
				//特殊处理返回结果
				if((Readbuf[1] == 0x62) && ((Readbuf[2]&0xFF) == 0xF1) && (((Readbuf[3]&0xFF) == 0x88) || ((Readbuf[3]&0xFF) == 0xC0)))
				{
					byte [] v_soft = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf, 4, v_soft, 0, Readbuf[0] - 3);
					String v_softver = new String(v_soft);
					showProcessList(v_softver,Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x62) //读数据
				{
					byte [] v_data = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf, 4, v_data, 0, Readbuf[0] - 3);
					String v_show = "";
					String v_get = "";
					int v_code = (Readbuf[2]&0xFF) * 0x100 + (Readbuf[3]&0xFF);
					switch(v_code)
					{
						case 0xF190:
							v_show = new String(v_data);
							v_get = new String(cartype.vin);
							break;
						case 0xF187:
							v_show = new String(v_data);
							v_show = v_show.replace(" ", "");
							v_show = v_show.trim();
							v_get = "";
							break;
						case 0xF18A:
						case 0xF188:
						case 0xF191:
							v_show = new String(v_data);
							v_get = "";
							break;
					}
					v_show = v_show.replace(" ", "");
					v_show = v_show.trim();
					if(v_get.length() > 0)
					{

					}
					else
					{
						showProcessList(v_show,Common.NULL,Common.OK);
					}
				}
				else if(i == 20) //下载driver
				{
					showProcessList("块数据:" + (v_down_block + 1),Common.NULL  ,Common.OK);
				}
				else if(i == 22) //结束下载app
				{
					showProcessList("块数据:" + (v_down_block + 1),Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x54) //清故障码
				{
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x59) //读故障码
				{
					//处理故障码
					byte [] dtc = new byte[256];
					dtc[0] = (byte) (((Readbuf[0]&0xFF) - 3) / 4);
					System.arraycopy(Readbuf, 4, dtc, 1, Readbuf[0] - 3);
					ArrayList<Map<String,String>> dtclist = new ArrayList<Map<String,String>>();
					showProcessList("无故障",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x67 && ((Readbuf[2]&0x01) == 0x01) ) //seed
				{
					System.arraycopy(Readbuf, 3, seed, 0, Readbuf[0] - 2);
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x74)
				{
					v_maxlen = (Readbuf[3]& 0xFF) * 0x100 + (Readbuf[4]& 0xFF);
				}
				else if(Readbuf[1] == 0x51)
				{
					Sleep(1000);
					showProcessList( "",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x71 && Readbuf[2] == 0x03 && Readbuf[4] == 0x00)
				{
					if(Readbuf[5] == 0x03)
					{
						i --;
						Sleep(1000);
					}
					else if(Readbuf[5] == 0x02)
					{
						showProcessList("",Common.NULL,Common.OK);
					}
					else
					{
						showProcessList("" + (Readbuf[5] & 0xFF),Common.NULL,Common.NG);
						break;
					}
				}
				else if(i == 23)
				{
					showProcessList("",Common.NULL,Common.OK);
					Sleep(200);
					if(v_down_block < 4)
					{
						v_down_block ++;
						i -= 5;
					}
				}
				else if(Readbuf[1] == 0x51)
				{
					showProcessList( "",Common.NULL,Common.OK);
					Sleep(1000);
				}
				else
				{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}
	private void fun_JX65_TcuFlash1(Section Pstep,String Pname)
	{
		int num = Integer.valueOf(Pstep.get("NUM"));
		stepId = Integer.valueOf(Pstep.get("MODULE_ID"));
		String Pmodule = Pstep.get("MODULE");
		String step_t = null;
		String step_name = null;
		byte [] Readbuf = new byte[512];
		byte [] seed = new byte[4];
		byte [] key = new byte[4];
		int v_maxlen = 0;
		short v_crc = (short) 0xFFFF;
		int [] canid = new int[2];
		if (Common.Communication==0) {
			if(!SetCanInitial(Pmodule,canid)) {
				showProcessList("设置通讯盒",Common.NULL, Common.NG);
				return;
			}
			SetCanInitTimer(0);
			SetCanMode(1,500000);
		}else {
			if(!m_com.SetCanBaud(500000))
			{
				showProcessList("设置波特率",Common.NULL,Common.NG);
				return;
			}
			if(!m_com.SetCanMode(2))
			{
				showProcessList("设置CanMode",Common.NULL,Common.NG);
				return;
			}
			if(!m_com.SetCommunTimer(5, 1000, 5000, 0))
			{
				showProcessList("设置时序",Common.NULL,Common.NG);
				return;
			}
			Can can = cartype.getCan(Pstep.get("MODULE"));
			canid[0] = can.getSendid();
			canid[1] = can.getRecvid();
		}
		//SetCanInitTimer(0);
		//先解析刷写数据
		String v_app_file = "";
		String v_dri_file = "";
		byte [] appbuf = null;
		//int v_applen = 0;
		byte [] dribuf = null;
		//int v_drilen = 0;
		byte [] v_dri_adr = new byte[256];
		byte [] v_dri_len = new byte[4];
		int [] v_dri_block = new int[10];
		int v_drilength = 0;
		byte [] v_app_adr = new byte[512];
		byte [] v_app_len = new byte[4];
		int [] v_app_block = new int[100];
		int v_applength = 0;
		int v_down_block = 0; //已经下载的块数
		int v_down_length = 0;
		int v_app_down = 0;
		//driver
		int v_dri_down_block = 0;
		int v_dri_down_length = 0;
		int v_dri_down = 0;
		byte [] cmd_link = {0x02,0x3e,(byte) 0x80};
		int error = 0;
		String tcu_name = "";
		tcu_name = CommonXml.GetEcuFlashName(cartype.mesinfo, "TCU_FLASH");
		if(tcu_name == null)
			tcu_name = Pstep.get("Flash");
		if(tcu_name == null)
		{
			showProcessList("获取文件信息失败!",Common.NULL,Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++)
		{
			//Pid += 1;
			step_t = Pstep.get("T" + i);
			stepName = Pstep.get("T" + i + "_NAME");
			if(step_t == null) break;
			if(step_t.length() < 3) continue;
			if(step_t.substring(0, 3).equals("CMD"))  //cmd
			{
				//获取cmd长度
				int cmdlen = Commonfunc.hexStringtoInt(step_t.substring(4, 6)) + 1;
				byte [] cmd = new byte[cmdlen];
				if(Commonfunc.CmdStringToBytes(step_t.substring(4), cmd, cmdlen) != cmd.length) return;
				showTip(step_name + "...");
				//---------------------发送前处理---------------------
				//解析下载文件
				if(i == 5)
				{
					//先解析driver文件
					showTip("解析Driver文件...");
					v_dri_file = Common.FLASH +  "TCU/" + tcu_name + "/CB1_SBl.bin";
					v_app_file = Common.FLASH +  "TCU/" + tcu_name + "/APPL.bin";
					if(v_dri_file.length() > 5)
					{
						if(".bin".equals(v_dri_file.substring(v_dri_file.length() - 4)) )
						{
							try {
								v_drilength = Commonfunc.GetBinFileLength(v_dri_file);
								v_dri_adr[0] = 0x01;
								v_dri_adr[1] = 0x60;
								v_dri_adr[2] = 0x00;
								v_dri_adr[3] = 0x00;
								v_dri_adr[4] = 0x00;
								v_dri_block[0] = 0x010000;
								v_dri_block[1] = 0x010000;
							} catch (IOException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
								v_drilength = 0;
								m_com.m_log.PrintLog("Open File Fialed:" + v_dri_file);
								showProcessList("打开Driver文件" + v_dri_file,Common.NULL,Common.NG);
								break;
							}
							//
							dribuf = new byte[v_drilength + 10];
							if(".bin".equals(v_dri_file.substring(v_dri_file.length() - 4)))
								try {
									v_drilength = Commonfunc.ReadBinFile(v_dri_file, dribuf);
								} catch (IOException e) {
									// TODO Auto-generated catch block
									e.printStackTrace();
									v_drilength = 0;
									showProcessList("解析Driver文件" + v_dri_file,Common.NULL,Common.NG);
									break;
								}

							if(v_drilength <= 10)
							{
								showProcessList("Driver数据解析" + v_dri_file,Common.NULL,Common.NG);
								break;
							}
						}
					}
					showTip("解析app文件...");

					//String v_appname ="APPL.bin";
					//v_app_file = Common.Dir + Common.GuestName + "/" + Common.cartype.carmode_dir +  "/TCU/" +  Common.cartype.mesinfo.flash_tcu + "/" +  v_appname;
					if((v_app_file != null) && (v_app_file.length() > 5))
					{
						if(".bin".equals(v_app_file.substring(v_app_file.length() - 4)) || ".BIN".equals(v_app_file.substring(v_app_file.length() - 4)))
						{
							try {
								v_applength = Commonfunc.GetBinFileLength(v_app_file);
								v_app_adr[0] = 1;
								v_app_adr[1] = (byte) 0x80;
								v_app_adr[2] = 0x04;
								v_app_adr[3] = 0x00;
								v_app_adr[4] = 0x00;
							} catch (IOException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
								v_applength = 0;
								m_com.m_log.PrintLog("Open File Fialed:" + v_app_file);
								showProcessList("打开app文件" + v_app_file,Common.NULL,Common.NG);
								break;
							}
						}
						//
						appbuf = new byte[v_applength + 10];
						v_applength = 0;
						if(".bin".equals(v_app_file.substring(v_app_file.length() - 4)) || ".BIN".equals(v_app_file.substring(v_app_file.length() - 4)))
						{
							try {
								v_applength = Commonfunc.ReadBinFile_TsingShan(v_app_file, appbuf);
								//v_applength = 0x0B8356;
								v_app_block[0] = v_applength;
								v_app_block[1] = v_applength;
							} catch (IOException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
								showProcessList("解析app文件" + v_app_file,Common.NULL,Common.NG);
								break;
							}
						}
						if(v_applength < 100)
						{
							showProcessList("App数据解析失败" + v_app_file,Common.NULL,Common.NG);
							break;
						}
					}
				}
				else if(cmd[1] == 0x27 && cmd[2] == 0x02) //安全认证
				{
					if((seed[0] | seed[1] | seed[2] | seed[3]) == 0) continue;
					//EolFunction.Changan_SafeCode_level(seed,key,0x61E47D07);
					Security.CX62B_TCM_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				}
				else if(cmd[1] == 0x2E) //写
				{
					int v_code = (cmd[2]&0xFF) * 0x100 + (cmd[3]&0xFF);
					switch(v_code)
					{
						case 0xF199:
							System.arraycopy(cartype.time, 0, cmd, 4, cmd[0] - 3);
							break;
					}
				}
				else if(i == 14) //开始下载驱动
				{
					if(v_drilength < 10) //无需下载驱动
					{
						i += 3;
						continue;
					}
					else //下载驱动,驱动暂时按单块处理,FLR也是多块
					{
						if(v_dri_down_block < v_dri_block[0])
						{
							System.arraycopy(v_dri_adr, 1 + 4 * v_dri_down_block, cmd, 4, 4);
							v_dri_len[0] = (byte) ((v_dri_block[1 + v_dri_down_block] >>> 24) & 0xFF);
							v_dri_len[1] = (byte) ((v_dri_block[1 + v_dri_down_block] >>> 16) & 0xFF);
							v_dri_len[2] = (byte) ((v_dri_block[1 + v_dri_down_block] >>> 8) & 0xFF);
							v_dri_len[3] = (byte) ((v_dri_block[1 + v_dri_down_block] >>> 0) & 0xFF);
							v_dri_down_length += v_dri_block[1 + v_dri_down_block];
							System.arraycopy(v_dri_len, 0, cmd, 8, 4);
						}
					}
				}
				else if(i == 15) //下载驱动
				{
					byte [] cmd_down = new byte[v_maxlen + 2];
					int v_len = 0;
					int v_start = 0;
					int v_frame = 1;
					while(v_dri_down < v_dri_down_length)
					{
						if((v_dri_down + v_maxlen - 2) >= v_dri_down_length) //last
						{
							v_len = v_dri_down_length - v_dri_down;
						}
						else
						{
							v_len = v_maxlen - 2;
						}
						if((v_len + 2) >= 0x100)
						{
							v_start = 1;
							cmd_down[0] = (byte) ((v_len + 2) / 0x100);
						}
						else
							v_start = 0;
						//拷贝数据
						cmd_down[v_start ++] = (byte) ((v_len + 2) % 0x100);
						cmd_down[v_start ++] = 0x36;
						cmd_down[v_start ++] = (byte)(v_frame ++);
						System.arraycopy(dribuf, v_dri_down, cmd_down, v_start, v_len);

						error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd_down,v_len+v_start, Readbuf, 5003, Common.CMD_MAX_TIME * 3, 1);
						if((error > 100) || ((Readbuf[1]&0xFF) == 0x7F))//异常
						{
							break;
						}
						Sleep(5);
						m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
						v_dri_down += v_len;
						showTip("下载数据:" + v_drilength + "\\" +  v_dri_down);
					}
					v_dri_down_block ++;
				}
				else if(i == 17) //检查有效性
				{
					System.arraycopy(v_dri_adr, 1, cmd, 5, 4);
				}
				else if(i == 19) //擦除APP,按多个块处理
				{
					System.arraycopy(v_app_adr, 1 + 4 * v_down_block, cmd, 5, 4);
					v_app_len[0] = 0x00;
					v_app_len[1] = 0x3C;
					v_app_len[2] = 0x00;
					v_app_len[3] = 0x00;
					System.arraycopy(v_app_len, 0, cmd, 9, 4);
				}
				else if(i == 20) //请求下载APP
				{
					System.arraycopy(v_app_adr, 1 + 4 * v_down_block, cmd, 4, 4);
					v_app_len[0] = (byte) ((v_applength >>> 24)&0xFF);
					v_app_len[1] = (byte) ((v_applength >>> 16)&0xFF);
					v_app_len[2] = (byte) ((v_applength >>> 8)&0xFF);
					v_app_len[3] = (byte) ((v_applength >>> 0)&0xFF);
					System.arraycopy(v_app_len, 0, cmd, 8, 4);
					v_down_length = v_applength;
				}
				else if(i == 21) //下载数据
				{
					byte [] cmd_down = new byte[v_maxlen + 2];
					int v_len = 0;
					int v_start = 0;
					int v_frame = 1;
					while(v_app_down < v_down_length)
					{
						if((v_app_down + v_maxlen - 2) >= v_down_length) //last
						{
							v_len = v_down_length - v_app_down;
						}
						else
						{
							v_len = v_maxlen - 2;
						}
						if((v_len + 2) >= 0x100)
						{
							v_start = 1;
							cmd_down[0] = (byte) ((v_len + 2) / 0x100);
						}
						else
							v_start = 0;
						//拷贝数据
						cmd_down[v_start ++] = (byte) ((v_len + 2) % 0x100);
						cmd_down[v_start ++] = 0x36;
						cmd_down[v_start ++] = (byte)(v_frame ++);
						System.arraycopy(appbuf, v_app_down, cmd_down, v_start, v_len);

						error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd_down,v_len+v_start, Readbuf, 5003, Common.CMD_MAX_TIME * 3, 1);
						if((error > 100) || ((Readbuf[1]&0xFF) == 0x7F))//异常
						{
							break;
						}
						Sleep(5);
						m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
						v_app_down += v_len;
						showTip("下载数据:" + v_applength + "\\" +  v_app_down);
					}
					v_down_block ++;
				}

				//特殊处理多次发送命令
				if(i == 15 || i == 21)
				{

				}
				else if(i == 5 || i == 6 || i == 7 || i == 25 || i == 26 || i == 27)
				{
					error = m_com.CanSendOneOnly(0x7DF, cmd, cmdlen);
					Sleep(Common.WAIT_TIME);
					continue;
				}
				else //普通发送命令
				{
					error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmdlen, Readbuf, 5003, Common.CMD_MAX_TIME * 2, 3);
					Sleep(50);
					m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
				}
				Sleep(Common.WAIT_TIME);
				//错误处理
				if(error == 5001) //通讯超时
				{
					if(i > 8)
					{
						showProcessList("通讯超时!",Common.NULL,Common.NG);
						break;
					}
					else
						continue;
				}
				else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					if(i > 8)
					{
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
						return;
					}
					else
						continue;
				}
				else if(error < 100) //异常回复
				{
					if((Readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
						break;
					}
				}
				//特殊处理返回结果
				if(i == 28 || i == 29 || i == 30)
				{
					byte [] v_soft = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf, 4, v_soft, 0, Readbuf[0] - 3);
					String v_softver = new String(v_soft);
					showProcessList(v_softver,Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x62) //读数据
				{
					byte [] v_data = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf, 4, v_data, 0, Readbuf[0] - 3);
					String v_show = "";
					String v_get = "";
					int v_code = (Readbuf[2]&0xFF) * 0x100 + (Readbuf[3]&0xFF);
					switch(v_code)
					{
						case 0xF190:
							v_show = new String(v_data);
							v_get = new String(cartype.vin);
							break;
						case 0xF187:
							v_show = new String(v_data);
							v_show = v_show.replace(" ", "");
							v_show = v_show.trim();
							v_get = "";
							break;
						case 0xF18A:
							v_show = new String(v_data);
							v_get = "";
							break;
					}
					v_show = v_show.replace(" ", "");
					v_show = v_show.trim();
					if(v_get.length() > 0)
					{
						if(v_show.equals(v_get))
							showProcessList(v_show,v_get,Common.OK);
						else
						{
							showProcessList(v_show ,v_get,Common.NG);
							break;
						}
					}
					else
					{
						showProcessList(v_show,Common.NULL,Common.NULL);
					}
				}
				else if(i == 16) //结束下载driver
				{
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(i == 22) //结束下载app
				{
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x54) //清故障码
				{
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x59) //读故障码
				{
					//处理故障码
					byte [] dtc = new byte[256];
					dtc[0] = (byte) (((Readbuf[0]&0xFF) - 3) / 4);
					System.arraycopy(Readbuf, 4, dtc, 1, Readbuf[0] - 3);
					ArrayList<Map<String,String>> dtclist = new ArrayList<Map<String,String>>();
					showProcessList("无故障",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x67 && Readbuf[2] == 0x01) //seed
				{
					System.arraycopy(Readbuf, 3, seed, 0, Readbuf[0] - 2);
				}
				else if(Readbuf[1] == 0x74)
				{
					v_maxlen = (Readbuf[3]& 0xFF) * 0x100 + (Readbuf[4]& 0xFF);
				}
				else if(Readbuf[1] == 0x51)
				{
					Sleep(1000);
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x71 && Readbuf[2] == 0x03 && Readbuf[4] == 0x00)
				{
					if(Readbuf[5] == 0x03)
					{
						i --;
						Sleep(1000);
					}
					else if(Readbuf[5] == 0x02)
					{
						showProcessList("",Common.NULL,Common.OK);
					}
					else
					{
						showProcessList("" + (Readbuf[5] & 0xFF),Common.NULL,Common.OK);
						break;
					}
				}
				else if(Readbuf[1] == 0x71 && Readbuf[2] == 0x01)
				{
					if((i == 21) && Pname.equals("BDCM"))
					{
						if(Readbuf[5] == 0x02) //ok
							showProcessList("",Common.NULL,Common.OK);
						else
							showProcessList( "",Common.NULL,Common.NG);
					}
					else
						showProcessList("",Common.NULL,Common.OK);
					Sleep(1000);
				}
				else if(Readbuf[1] == 0x51)
				{
					showProcessList( "",Common.NULL,Common.OK);
					Sleep(1000);
				}
				else
				{
					showProcessList( "",Common.NULL,Common.OK);
				}
			}
		}
	}
	private void fun_PHEV_FrmFlash(Profile.Section Pstep,String Pname)
	{
		int num = Integer.valueOf(Pstep.get("NUM"));
		stepId = Integer.valueOf(Pstep.get("MODULE_ID"));
		String Pmodule = Pstep.get("MODULE");
		String step_t = null;
		String step_name = null;
		byte [] Readbuf = new byte[512];
		byte [] seed = new byte[4];
		byte [] key = new byte[4];
		int [] canid = new int[2];
		SetCanInitTimer(0);
		SetCanMode(1,500000);
		if (Common.Communication==0){
			if(!SetCanInitial(Pstep.get("MODULE"),canid)) {
				showProcessList("设置通讯盒",Common.NULL, Common.NG);
				return;
			}
			SetCanInitTimer(0);
			SetCanMode(1,500000);
		}else{
			if(!SetCanInitial_Flash(Pmodule, canid))
			{
				showProcessList("设置波特率",Common.NULL,Common.NG);
				return;
			}
			if(!m_com.SetCanMode(2))
			{
				showProcessList("设置CanMode",Common.NULL,Common.NG);
				return;
			}
		}

		byte [] frmdata = null;
		String frmfile = "";
		if (((cartype.byteConfig[152]) & 0x01)==0x01){ // 存在APA
			frmfile = Pstep.get("FILE");
		} else{ // 不存在APA
			frmfile = Pstep.get("FILEAPA");
		}
		if (frmfile!=null||frmfile.length()>5){
			frmdata = CommonXml.ReadFrmXmlFile(cartype.carDirectory +"FRM/" + frmfile);
			if(frmdata == null)
			{
				m_com.m_log.PrintLog("Open File Fialed:" + frmfile);
				showProcessList("解析FRM文件","打开文件失败:" + frmfile,Common.NG);
				return;
			}
		}
		byte [] cmd_down = null;
		int error = 0;
		for(int i = 1; i < (num + 1); i ++)
		{
			//Pid += 1;
			step_t = Pstep.get("T" + i);
			stepName = Pstep.get("T" + i + "_NAME");
			if(step_t == null) break;
			if(step_t.length() < 3) continue;
			if(step_t.substring(0, 3).equals("CMD"))  //cmd
			{
				//获取cmd长度
				int cmdlen = Commonfunc.HexStringtoInt(step_t.substring(4, 6)) + 1;
				byte [] cmd = new byte[cmdlen];
				if(Commonfunc.CmdStringToBytes(step_t.substring(4), cmd, cmdlen) != cmd.length) return;
				showTip(step_name + "...");
				//---------------------发送前处理---------------------
				//解析下载文件
				if(cmd[1] == 0x27 && cmd[2] == 0x04) //安全认证
				{
					if((seed[0] | seed[1] | seed[2] | seed[3]) == 0) continue;
					Security.S32EV_ABS_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				}
				else if(cmd[1] == 0x2E) //写
				{
					cmdlen = frmdata.length + 3;
					cmd_down = new byte[cmdlen + 2];
					//拷贝数据
					cmd_down[0] = (byte) ((cmdlen) / 0x100);
					cmd_down[1] =  (byte) ((cmdlen) % 0x100);
					cmd_down[2] = 0x2E;
					cmd_down[3] = 0x4F;
					cmd_down[4] = (byte) 0x8E;
					System.arraycopy(frmdata, 0, cmd_down, 5, frmdata.length);
					cmdlen += 2;
				}

				//特殊处理多次发送命令
				if(i == 5)
				{
					error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd_down,cmdlen, Readbuf, 5003, Common.CMD_MAX_TIME * 2, 1);
				}
				else //普通发送命令
				{
					error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmdlen, Readbuf, 5003, Common.CMD_MAX_TIME * 2,1);
				}
				Sleep(Common.waittime);
				//错误处理
				if(error == 5001) //通讯超时
				{
					showProcessList("通讯超时!",Common.NULL,Common.NG);
					break;
				}
				else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
					return;
				}
				else if(error < 100) //异常回复
				{
					if((Readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
						break;
					}
				}

				//特殊处理返回结果
				if((Readbuf[1] == 0x62) && ((Readbuf[2]&0xFF) == 0xF1) && (((Readbuf[3]&0xFF) == 0x88) || ((Readbuf[3]&0xFF) == 0xC0)))
				{
					byte [] v_soft = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf, 4, v_soft, 0, Readbuf[0] - 3);
					String v_softver = new String(v_soft);
					//String v_getsoft = Common.cartype.getModuleStr(Pname,partnumber_cache, "appFileVersionLatest");
					showProcessList(v_softver,Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x62) //读数据
				{
					byte [] v_data = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf, 4, v_data, 0, Readbuf[0] - 3);
					String v_show = "";
					String v_get = "";
					int v_code = (Readbuf[2]&0xFF) * 0x100 + (Readbuf[3]&0xFF);
					switch(v_code)
					{
						case 0xF190:
							v_show = new String(v_data);
							v_get = new String(Common.cartype.vin);
							break;
						case 0xF187:
							v_show = new String(v_data);
							v_show = v_show.replace(" ", "");
							v_show = v_show.trim();
							v_get = "";
							break;
						case 0xF18A:
							v_show = new String(v_data);
							v_get = "";
							break;
						default:
							v_show = new String(v_data);
							v_get = "";
							break;
					}
					v_show = v_show.replace(" ", "");
					v_show = v_show.trim();
					if(v_get.length() > 0)
					{
						if(v_show.equals(v_get))
							showProcessList(v_show,v_get,Common.OK);
						else if(Common.cartype.OptMode == 1)
							showProcessList(v_show , v_get ,Common.NULL);
						else
						{
							showProcessList(v_show ,v_get ,Common.NG);
							break;
						}
					}
					else
					{
						showProcessList(v_show,Common.NULL,Common.NULL);
					}
				}
				else if(Readbuf[1] == 0x54) //清故障码
				{
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x59) //读故障码
				{
					//处理故障码
					byte [] dtc = new byte[256];
					dtc[0] = (byte) (((Readbuf[0]&0xFF) - 3) / 4);
					System.arraycopy(Readbuf, 4, dtc, 1, Readbuf[0] - 3);
					ArrayList<Map<String,String>> dtclist = new ArrayList<Map<String,String>>();
					showProcessList("无故障",Common.NULL,Common.NG);
				}
				else if(Readbuf[1] == 0x67 && Readbuf[2] == 0x03) //seed
				{
					System.arraycopy(Readbuf, 3, seed, 0, Readbuf[0] - 2);
				}
				else if(Readbuf[1] == 0x51)
				{
					showProcessList( "",Common.NULL,Common.OK);
					Sleep(1000);
				}
				else
				{
					showProcessList( "",Common.NULL,Common.OK);
				}
			}
		}
	}
	private void fun_PHEV_Fcmflash(Section Pstep,String Pname)
	{
		int num = Integer.valueOf(Pstep.get("NUM"));
		stepId = Integer.valueOf(Pstep.get("MODULE_ID"));
		String Pmodule = Pstep.get("MODULE");
		String step_t = null;
		String step_name = null;
		byte [] Readbuf = new byte[512];
		byte [] seed = new byte[10];
		byte [] key = new byte[10];
		int v_maxlen = 0;
		short v_crc = (short) 0xFFFF;
		int [] canid = new int[2];
		if (Common.Communication==0){
			if(!SetCanInitial(Pmodule,canid)) {
				showProcessList("设置通讯盒",Common.NULL, Common.NG);
				return;
			}
			SetCanInitTimer(3);
			SetCanMode(1,500000);
		}else {
			if(!m_com.SetCanBaud(500000))
			{
				showProcessList("设置波特率",Common.NULL,Common.NG);
				return;
			}
			if(!m_com.SetCanMode(2))
			{
				showProcessList("设置CanMode",Common.NULL,Common.NG);
				return;
			}
			if(!m_com.SetCommunTimer(5, 1000, 5000, 0))
			{
				showProcessList("设置时序",Common.NULL,Common.NG);
				return;
			}

			Can can = cartype.getCan(Pstep.get("MODULE"));
			canid[0] = can.getSendid();
			canid[1] = can.getRecvid();
		}

		String flash_app = Pstep.get("FILE");
		String flash_driver = Pstep.get("DRIVER");
		if(flash_app == null)
		{
			showProcessList("Mes推送数据为空",Common.NULL,Common.NG);
			return;
		}
		//先解析刷写数据
		String v_app_file = "";
		String v_dri_file = "";
		byte [] appbuf = null;
		//int v_applen = 0;
		byte [] dribuf = null;
		//int v_drilen = 0;
		int v_drilength = 0;
		byte [] v_dri_adr = new byte[256];
		int [] v_dri_block = new int[10];
		byte [] v_app_adr = new byte[512];
		int v_applength = 0;
		int v_down_length = 0;
		int v_dridown_length = 0;
		int v_app_down = 0;
		int v_dri_down=0;
		int [] v_app_block = new int[100];
		int v_down_block = 0; //已经下载的块数
		//driver
		short v_calc = 0;
		byte [] cmd_link = {0x02,0x3e,(byte) 0x80};
		int error = 0;
		for(int i = 1; i < (num + 1); i ++)
		{
			//Pid += 1;
			step_t = Pstep.get("T" + i);
			stepName  = Pstep.get("T" + i + "_NAME");
			if(step_t == null) break;
			if(step_t.length() < 3) continue;
			if(step_t.substring(0, 3).equals("CMD"))  //cmd
			{
				//获取cmd长度
				int cmdlen = Commonfunc.hexStringtoInt(step_t.substring(4, 6)) + 1;
				byte [] cmd = new byte[cmdlen];
				if(Commonfunc.CmdStringToBytes(step_t.substring(4), cmd, cmdlen) != cmd.length) return;
				showTip(stepName + "...");
				//---------------------发送前处理---------------------
				//解析下载文件
				if(i == 1)
				{
					//先解析driver文件
					showTip("解析Driver文件...");
					if(flash_app == null)
					{
						showProcessList("Mes推送数据为空",Common.NULL,Common.NG);
						return;
					}
					else
					{
						v_dri_file = cartype.carDirectory +  "FCM/" +  flash_driver;
						v_app_file = cartype.carDirectory  +  "FCM/" +  flash_app;
					}
					if((v_dri_file != null) && (v_dri_file.length() > 15))
					{
						try {
							v_drilength = Commonfunc.GetS19FileLength(v_dri_file, v_dri_adr);
							dribuf = new byte[v_drilength + 10];
							v_drilength = Commonfunc.ReadS19File(v_dri_file, dribuf, 0, v_dri_block);
							 v_dridown_length = v_drilength;
						} catch (IOException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
//						if(v_drilength != 16)
//						{
//							m_com.m_log.PrintLog("Open File Fialed:" + v_dri_file);
//							showProcessList("Driver数据解析:" + v_dri_file,Common.NULL,Common.NG);
//							break;
//						}
					}
					if((v_app_file != null) && (v_app_file.length() > 15)){
						showTip("解析app文件...");
						try {
							v_applength = Commonfunc.GetS19FileLength(v_app_file, v_app_adr);
							appbuf = new byte[v_applength + 10];
							v_applength = Commonfunc.ReadS19File(v_app_file, appbuf, 0, v_app_block);
							v_calc = Commonfunc.me1781_CalcCRC16(appbuf, 0, v_applength,(short)0xffff);
							v_down_length = v_applength;
						} catch (IOException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
						if(v_applength < 10)
						{
							m_com.m_log.PrintLog("Open File Fialed:" + v_app_file);
							showProcessList("App数据解析:" + v_app_file,Common.NULL,Common.NG);
							break;
						}
						else
							showProcessList("App数据解析:" + v_app_file,Common.NULL,Common.OK);
					}
				}
				else if(cmd[1] == 0x27 && cmd[2] == 0x04) //安全认证
				{
					if((seed[0] | seed[1] | seed[2] | seed[3]) == 0) continue;
					Security.Cx62B_FCM_Level2(seed, key,0x5400);
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				}
				else if(cmd[1] == 0x2E) //写
				{
					int v_code = (cmd[2]&0xFF) * 0x100 + (cmd[3]&0xFF);
					switch(v_code)
					{
						case 0xF199:
							System.arraycopy(cartype.time, 0, cmd, 4, cmd[0] - 3);
							break;
					}
				}
				else if(i == 8) //下载驱动
				{
					byte [] cmd_down = new byte[v_maxlen + 2];
					int v_len = 0;
					int v_start = 0;
					int v_frame = 1;
					v_dri_down = 0;
					while(v_dri_down < v_dridown_length)
					{
						if((v_dri_down + v_maxlen - 2) >= v_dridown_length) //last
						{
							v_len = v_dridown_length - v_dri_down;
						}
						else
						{
							v_len = v_maxlen - 2;
						}
						if((v_len + 2) >= 0x100)
						{
							v_start = 1;
							cmd_down[0] = (byte) ((v_len + 2) / 0x100);
						}
						else
							v_start = 0;
						//拷贝数据
						cmd_down[v_start ++] = (byte) ((v_len + 2) % 0x100);
						cmd_down[v_start ++] = 0x36;
						cmd_down[v_start ++] = (byte)(v_frame ++);
						System.arraycopy(dribuf, v_dri_down, cmd_down, v_start, v_len);
						error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd_down,v_len+v_start, Readbuf, 5003, Common.CMD_MAX_TIME * 3, 1);
						if((error > 100) || ((Readbuf[1]&0xFF) == 0x7F))//异常
						{
							break;
						}
						Sleep(5);
						m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
						v_dri_down += v_len;
						showTip("下载数据:" + v_drilength + "\\" +  v_dri_down);
					}
				}
				else if(i == 14) //下载数据
				{
					byte [] cmd_down = new byte[v_maxlen + 2];
					int v_len = 0;
					int v_start = 0;
					int v_frame = 1;
					v_app_down = 0;
					while(v_app_down < v_down_length)
					{
						if((v_app_down + v_maxlen - 2) >= v_down_length) //last
						{
							v_len = v_down_length - v_app_down;
						}
						else
						{
							v_len = v_maxlen - 2;
						}
						if((v_len + 2) >= 0x100)
						{
							v_start = 1;
							cmd_down[0] = (byte) ((v_len + 2) / 0x100);
						}
						else
							v_start = 0;
						//拷贝数据
						cmd_down[v_start ++] = (byte) ((v_len + 2) % 0x100);
						cmd_down[v_start ++] = 0x36;
						cmd_down[v_start ++] = (byte)(v_frame ++);
						System.arraycopy(appbuf, v_app_down, cmd_down, v_start, v_len);
						error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd_down,v_len+v_start, Readbuf, 5003, Common.CMD_MAX_TIME * 3, 1);
						if((error > 100) || ((Readbuf[1]&0xFF) == 0x7F))//异常
						{
							break;
						}
						Sleep(5);
						m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
						v_app_down += v_len;
						showTip("下载数据:" + v_applength + "\\" +  v_app_down);
					}
					v_down_block ++;
				}
				else if(i == 16)
				{
					cmd[13] = (byte) ((v_calc >> 8) & 0xFF);
					cmd[14] = (byte) (v_calc & 0xFF);
				}
				else if(i == 19)
				{
					cmd[5] = (byte) ((v_calc >> 8) & 0xFF);
					cmd[6] = (byte) (v_calc & 0xFF);
				}

				//特殊处理多次发送命令
				if(i == 14||i==8)
				{

				}
				else if(i == 1 || i == 2 || i == 3 || i == 23 || i == 24 || i == 25)
				{
					error = m_com.CanSendOneOnly(0x7DF, cmd, cmdlen);
					Sleep(Common.WAIT_TIME);
					continue;
				}
				else //普通发送命令
				{
					error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmdlen, Readbuf, 5003, Common.CMD_MAX_TIME * 2, 3);
					Sleep(50);
					m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
				}
				Sleep(Common.WAIT_TIME);
				//错误处理
				if(error == 5001) //通讯超时
				{
					if(i > 8)
					{
						showProcessList("通讯超时!",Common.NULL,Common.NG);
						break;
					}
					else
						continue;
				}
				else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					if(i > 8)
					{
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
						return;
					}
					else
						continue;
				}
				else if(error < 100) //异常回复
				{
					if((Readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
						break;
					}
				}
				//特殊处理返回结果
				if(i == 28 || i == 29 || i == 30)
				{
					byte [] v_soft = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf, 4, v_soft, 0, Readbuf[0] - 3);
					String v_softver = new String(v_soft);
					showProcessList(v_softver,Common.NULL,Common.OK);
					if(t_print == null)
						t_print = new ArrayList<String>();
					t_print.add(step_name + ": " + v_softver);
				}
				else if(Readbuf[1] == 0x62) //读数据
				{
					byte [] v_data = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf, 4, v_data, 0, Readbuf[0] - 3);
					String v_show = "";
					String v_get = "";
					int v_code = (Readbuf[2]&0xFF) * 0x100 + (Readbuf[3]&0xFF);
					switch(v_code)
					{
						case 0xF190:
							v_show = new String(v_data);
							v_get = new String(cartype.vin);
							break;
						case 0xF187:
							v_show = new String(v_data);
							v_show = v_show.replace(" ", "");
							v_show = v_show.trim();
							v_get = "";
							break;
						case 0xF18A:
							v_show = new String(v_data);
							v_get = "";
							break;
					}
					v_show = v_show.replace(" ", "");
					v_show = v_show.trim();
					if(v_get.length() > 0)
					{
						showProcessList(v_show,v_get,Common.OK);
					}
					else
					{
						showProcessList(v_show,Common.NULL,Common.NULL);
					}
				}
				else if(i == 9) //结束下载driver
				{
					//showProcessList("",Common.NG);
				}
				else if(i == 15) //结束下载app
				{
					//showProcessList("",Common.NG);
				}
				else if(Readbuf[1] == 0x54) //清故障码
				{
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x59) //读故障码
				{
					//处理故障码
					byte [] dtc = new byte[256];
					dtc[0] = (byte) (((Readbuf[0]&0xFF) - 3) / 4);
					System.arraycopy(Readbuf, 4, dtc, 1, Readbuf[0] - 3);
					ArrayList<Map<String,String>> dtclist = new ArrayList<Map<String,String>>();
					showProcessList("无故障",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x67 && Readbuf[2] == 0x03) //seed
				{
					System.arraycopy(Readbuf, 3, seed, 0, Readbuf[0] - 2);
				}
				else if(Readbuf[1] == 0x74)
				{
					v_maxlen = (Readbuf[3]& 0xFF) * 0x100 + (Readbuf[4]& 0xFF);
				}
				else if(Readbuf[1] == 0x51)
				{
					Sleep(1000);
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x71 && Readbuf[2] == 0x03 && Readbuf[4] == 0x00)
				{
					if(Readbuf[5] == 0x03)
					{
						i --;
						Sleep(1000);
					}
					else if(Readbuf[5] == 0x02)
					{
						showProcessList("",Common.NULL,Common.OK);
					}
					else
					{
						showProcessList("" + (Readbuf[5] & 0xFF),Common.NULL,Common.NG);
						break;
					}
				}
				else if(Readbuf[1] == 0x71 && Readbuf[2] == 0x01)
				{
					showProcessList( "",Common.NULL,Common.OK);
					Sleep(1000);
				}
				else if(Readbuf[1] == 0x51)
				{
					showProcessList("",Common.NULL,Common.OK);
					Sleep(1000);
				}
				else
				{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}
	private void fun_PHEV_Ecuflash(Section Pstep,String Pname)  //修改成蓝牙模式
	{
		int num = Integer.valueOf(Pstep.get("NUM"));
		int Pid = Integer.valueOf(Pstep.get("MODULE_ID"));
		String Pmodule = Pstep.get("MODULE");
		String step_t = null;
		String step_name = null;
		byte [] seed = new byte[10];
		byte [] key = new byte[10];
		int v_maxlen = 0;
		int v_d002len = 388;
		int v_d002lastlen = 388;
		int v_d004len = 388;
		short v_crc = (short) 0xFFFF;
		int [] canid = new int[2];
		int [] v_app_block = new int[100];

		if (Common.Communication==0) {
			if(!SetCanInitial(Pstep.get("MODULE"),canid)) {
				showProcessList("设置通讯盒",Common.NULL, Common.NG);
				return;
			}
			SetCanInitTimer(0);
			SetCanMode(1,500000);
		}else {
			if(!m_com.SetCanBaud(500000))
			{
				showProcessList("设置波特率",Common.NULL,Common.NG);
				return;
			}
			if(!m_com.SetCanMode(2))
			{
				showProcessList("设置CanMode",Common.NULL,Common.NG);
				return;
			}
			if(!m_com.SetCommunTimer(5, 1000, 5000, 0))
			{
				showProcessList("设置时序",Common.NULL,Common.NG);
				return;
			}
			Can can = cartype.getCan(Pstep.get("MODULE"));
			canid[0] = can.getSendid();
			canid[1] = can.getRecvid();
		}

		String flash_driver = Pstep.get("DRIVER");
		String d002_rsa = Pstep.get("RSA02");
		String d002last_rsa = "'";
		String d004_rsa = Pstep.get("RSA04");
		String flash_ems = cartype.ems;//*F18-3605010AM*F01R0AD7PX*0x90000000-0x803FFFFF*
		if(flash_ems == null)
		{
			showProcessList("Mes推送数据为空,从本地获取","",Common.NULL);
			flash_ems = Pstep.get("FILE");
			d002last_rsa = Pstep.get("RSA02LAST");
			//return;
		}
		else
		{
			flash_ems = flash_ems.substring(5);
			int adr = flash_ems.indexOf("FF*");
			if(adr > 0)
			{
				flash_ems =flash_ems.substring(adr + 3);
				adr = flash_ems.indexOf("*");
				if(adr > 0)
					flash_ems = flash_ems.substring(0,adr);
			}
			if(flash_ems.length() < 5)
			{
				showProcessList("解析EMS文件","解析失败!",Common.NG);
				return;
			}
			d002last_rsa = flash_ems + ".rsa";
			flash_ems += ".bin";
		}
		if(flash_ems == null)
		{
			showProcessList("Mes推送数据为空",Common.NULL,Common.NG);
			return;
		}
		//先解析刷写数据
		String v_app_file = "";
		String v_dri_file = "";
		String v_d002_file="";
		String v_d002last_file="";
		String v_d004_file="";
		byte[] d002buf=null;
		byte[] d002lastbuf=null;
		byte[] d004buf=null;
		byte [] appbuf = null;
		//int v_applen = 0;
		byte [] dribuf = null;
		//int v_drilen = 0;
		int v_drilength = 0;
		int d002length=0;
		int d002lastlength=0;
		int d004length=0;
		byte [] v_dri_adr = new byte[256];
		int [] v_dri_block = new int[10];
		byte [] v_app_adr = new byte[512];
		int v_applength = 0;
		int v_down_length = 0;
		int v_downd002_length=0;
		int v_downd002last_length=0;
		int v_downd004_length=0;

		int v_app_down = 0;
		int v_d002_down = 0;
		int v_d002last_down = 0;
		int v_d004_down=0;
		int v_down_block = 0; //已经下载的块数
		//driver
		short v_calc = 0;
		byte [] cmd_link = {0x02,0x3e,(byte) 0x80};
		int error = 0;
		for(int i = 1; i < (num + 1); i ++)
		{
			Pid += 1;
			step_t = Pstep.get("T" + i);
			stepName  = Pstep.get("T" + i + "_NAME");
			if(step_t == null) break;
			if(step_t.length() < 3) continue;
			if(step_t.substring(0, 3).equals("CMD"))  //cmd
			{
				//获取cmd长度
				int cmdlen = Commonfunc.hexStringtoInt(step_t.substring(4, 6)) + 1;
				byte [] cmd = new byte[cmdlen];
				if(Commonfunc.CmdStringToBytes(step_t.substring(4), cmd, cmdlen) != cmd.length) return;
				showTip(stepName + "...");
				//---------------------发送前处理---------------------
				//解析下载文件
				if(i == 1)
				{
					//先解析driver文件
					showTip("解析Driver文件...");
					if(flash_ems == null)
					{
						showProcessList("Mes推送数据为空",Common.NULL,Common.NG);
						return;
					}
					else
					{
						v_dri_file = cartype.carDirectory +  "EMS/" +  flash_driver;
						v_app_file = cartype.carDirectory  +  "EMS/" +  flash_ems;
						v_d002_file = cartype.carDirectory+"EMS/"+d002_rsa;
						v_d002last_file = cartype.carDirectory+"EMS/"+d002last_rsa;
						v_d004_file = cartype.carDirectory+"EMS/"+d004_rsa;
					}
					if((v_dri_file != null) && (v_dri_file.length() > 15))
					{
						if(".HEX".equals(v_dri_file.substring(v_dri_file.length() - 4))||".hex".equals(v_dri_file.substring(v_dri_file.length() - 4))){
							try {
								v_drilength = Commonfunc.GetHexFileLength(v_dri_file, v_dri_adr);
								dribuf = new byte[v_drilength + 10];
								v_drilength = Commonfunc.ReadHexFile(v_dri_file,dribuf, v_dri_block);
							} catch (IOException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}
						}
						if(v_drilength != 16)

						{
							m_com.m_log.PrintLog("Open File Fialed:" + v_dri_file);
							showProcessList("Driver数据解析:" + v_dri_file,Common.NULL,Common.NG);
							break;
						}
					}
					showTip("解析app文件...");
					if(".HEX".equals(v_app_file.substring(v_app_file.length() - 4))||".hex".equals(v_app_file.substring(v_app_file.length() - 4)))
					{
						try {
							v_applength = Commonfunc.GetHexFileLength(v_app_file, v_app_adr);
							appbuf = new byte[v_applength + 10];
							v_applength = Commonfunc.ReadHexFile(v_app_file,appbuf,v_app_block);
							v_down_length = v_applength;
							v_calc = Commonfunc.me1781_CalcCRC16(appbuf, 0, v_applength,(short)0xffff);
						} catch (IOException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}else { //制作bin文件解析
						try {
							v_applength = Commonfunc.GetBinFileLength(v_app_file);
							appbuf = new byte[v_applength + 10];
							v_applength = Commonfunc.ReadBinFile(v_app_file, appbuf);
							v_down_length = v_applength;
							v_calc = Commonfunc.me1781_CalcCRC16(appbuf, 0, v_applength,(short)0xffff);
						} catch (IOException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}
					if(v_applength < 100)
					{
						m_com.m_log.PrintLog("Open File Fialed:" + v_app_file);
						showProcessList("App数据解析:" + v_app_file,Common.NULL,Common.NG);
						break;
					}
					else
						showProcessList("App数据解析:" + v_app_file,Common.NULL,Common.OK);

					showTip("解析验签文件...");
					if((v_d002_file != null)){
						try {
							d002length = Commonfunc.GetBinFileLength(v_d002_file);
							d002buf = new byte[d002length + 10];
							d002length = Commonfunc.ReadBinFile(v_d002_file, d002buf);
							v_downd002_length = d002length;
						} catch (IOException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}
					/*if((v_d002last_file != null)){
						try {
							d002lastlength = Commonfunc.GetBinFileLength(v_d002last_file);
							d002lastbuf = new byte[d002lastlength + 10];
							d002lastlength = Commonfunc.ReadBinFile(v_d002last_file, d002lastbuf);
							v_downd002last_length = d002lastlength;
						} catch (IOException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}*/
					//改为RSA文件
					if((v_d002last_file != null)){
						try {
							d002lastbuf = new byte[512];
							d002lastlength = Commonfunc.ReadRsaFile(v_d002last_file,d002lastbuf);
							v_downd002last_length = d002lastlength;
						} catch (IOException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}
					if((v_d004_file != null)){
						try {
							d004length = Commonfunc.GetBinFileLength(v_d004_file);
							d004buf = new byte[d004length + 10];
							d004length = Commonfunc.ReadBinFile(v_d004_file, d004buf);
							v_downd004_length = d004length;
						} catch (IOException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}
				}
				else if(cmd[1] == 0x27 && cmd[2] == 0x08) //安全认证
				{
					if((seed[0] | seed[1] | seed[2] | seed[3]) == 0) continue;
					Security.chery_ECU_safekey7(seed, key);
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				}
				else if(cmd[1] == 0x2E) //写
				{
					int v_code = (cmd[2]&0xFF) * 0x100 + (cmd[3]&0xFF);
					switch(v_code)
					{
						case 0xF199:
							System.arraycopy(cartype.time, 0, cmd, 4, cmd[0] - 3);
							break;
					}
				} else if (i==8) {  //下载验签数据
					byte [] cmd_down = new byte[v_d004len + 4];
					int v_len = 0;
					int v_start = 0;
					int v_frame = 4;
					v_d004_down = 0;
					while(v_d004_down < v_downd004_length)
					{
						if((v_d004_down + v_d004len - 4) >= v_downd004_length) //last
						{
							v_len = v_downd004_length - v_d004_down;
						}
						else
						{
							v_len = v_d004len - 4;
						}
						if((v_len + 4) >= 0x100)
						{
							v_start = 1;
							cmd_down[0] = (byte) ((v_len + 4) / 0x100);
						}
						else
							v_start = 0;
						//拷贝数据
						cmd_down[v_start ++] = (byte) ((v_len + 4) % 0x100);
						cmd_down[v_start ++] = 0x31;
						cmd_down[v_start ++] = 0x01;
						cmd_down[v_start ++] = (byte) 0xd0;
						cmd_down[v_start ++] = (byte)(v_frame ++);
						System.arraycopy(d004buf, v_d004_down, cmd_down, v_start, v_len);
						error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd_down,v_len+v_start, readbuf, 5003, Common.CMD_MAX_TIME * 3, 1);
						if((error > 100) || ((readbuf[1]&0xFF) == 0x7F))//异常
						{
							break;
						}
						Sleep(5);
						m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
						v_d004_down += v_len;
						showTip("下载验签:" + v_downd004_length + "\\" +  v_d004_down);
					}
				} else if (i==12) {
					byte [] cmd_down = new byte[v_d002len + 4];
					int v_len = 0;
					int v_start = 0;
					int v_frame = 2;
					v_d002_down = 0;
					while(v_d002_down < v_downd002_length)
					{
						if((v_d002_down + v_d002len - 4) >= v_downd002_length) //last
						{
							v_len = v_downd002_length - v_d002_down;
						}
						else
						{
							v_len = v_d002len - 4;
						}
						if((v_len + 4) >= 0x100)
						{
							v_start = 1;
							cmd_down[0] = (byte) ((v_len + 4) / 0x100);
						}
						else
							v_start = 0;
						//拷贝数据
						cmd_down[v_start ++] = (byte) ((v_len + 4) % 0x100);
						cmd_down[v_start ++] = 0x31;
						cmd_down[v_start ++] = 0x01;
						cmd_down[v_start ++] = (byte) 0xd0;
						cmd_down[v_start ++] = (byte)(v_frame ++);
						System.arraycopy(d002buf, v_d002_down, cmd_down, v_start, v_len);
						error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd_down,v_len+v_start, readbuf, 5003, Common.CMD_MAX_TIME * 3, 1);
						if((error > 100) || ((readbuf[1]&0xFF) == 0x7F))//异常
						{
							break;
						}
						Sleep(5);
						m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
						v_d002_down += v_len;
						showTip("下载验签:" + v_downd002_length + "\\" +  v_d002_down);
					}
				}else if (i==19) {
					byte [] cmd_down = new byte[v_d002lastlen + 4];
					int v_len = 0;
					int v_start = 0;
					int v_frame = 2;
					v_d002last_down = 0;
					while(v_d002last_down < v_downd002last_length)
					{
						if((v_d002last_down + v_d002lastlen - 4) >= v_downd002last_length) //last
						{
							v_len = v_downd002last_length - v_d002last_down;
						}
						else
						{
							v_len = v_d002lastlen - 4;
						}
						if((v_len + 4) >= 0x100)
						{
							v_start = 1;
							cmd_down[0] = (byte) ((v_len + 4) / 0x100);
						}
						else
							v_start = 0;
						//拷贝数据
						cmd_down[v_start ++] = (byte) ((v_len + 4) % 0x100);
						cmd_down[v_start ++] = 0x31;
						cmd_down[v_start ++] = 0x01;
						cmd_down[v_start ++] = (byte) 0xd0;
						cmd_down[v_start ++] = (byte)(v_frame ++);
						System.arraycopy(d002lastbuf, v_d002last_down, cmd_down, v_start, v_len);
						error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd_down,v_len+v_start, readbuf, 5003, Common.CMD_MAX_TIME * 3, 1);
						if((error > 100) || ((readbuf[1]&0xFF) == 0x7F))//异常
						{
							break;
						}
						Sleep(5);
						m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
						v_d002last_down += v_len;
						showTip("下载验签:" + v_downd002last_length + "\\" +  v_d002last_down);
					}
				}
				else if(i == 10) //下载驱动
				{
					//拷贝数据
					System.arraycopy(dribuf, 0, cmd, 3, v_drilength);
				}
				else if(i == 17) //下载数据
				{
					byte [] cmd_down = new byte[v_maxlen + 2];
					int v_len = 0;
					int v_start = 0;
					int v_frame = 1;
					v_app_down = 0;
					while(v_app_down < v_down_length)
					{
						if((v_app_down + v_maxlen - 2) >= v_down_length) //last
						{
							v_len = v_down_length - v_app_down;
						}
						else
						{
							v_len = v_maxlen - 2;
						}
						if((v_len + 2) >= 0x100)
						{
							v_start = 1;
							cmd_down[0] = (byte) ((v_len + 2) / 0x100);
						}
						else
							v_start = 0;
						//拷贝数据
						cmd_down[v_start ++] = (byte) ((v_len + 2) % 0x100);
						cmd_down[v_start ++] = 0x36;
						cmd_down[v_start ++] = (byte)(v_frame ++);
						System.arraycopy(appbuf, v_app_down, cmd_down, v_start, v_len);

						error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd_down,v_len+v_start, readbuf, 5003, Common.CMD_MAX_TIME * 3, 1);
						if((error > 100) || ((readbuf[1]&0xFF) == 0x7F))//异常
						{
							break;
						}
						Sleep(5);
						m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
						v_app_down += v_len;
						showTip("下载数据:" + v_applength + "\\" +  v_app_down);
					}
					v_down_block ++;
				}
//				else if(i == 18)
//				{
//					cmd[13] = (byte) ((v_calc >> 8) & 0xFF);
//					cmd[14] = (byte) (v_calc & 0xFF);
//				}
//				else if(i == 21)
//				{
//					cmd[5] = (byte) ((v_calc >> 8) & 0xFF);
//					cmd[6] = (byte) (v_calc & 0xFF);
//				}

				//特殊处理多次发送命令
				if(i == 17||i==8||i==12||i==19)
				{

				}
				else if(i == 1 || i == 2 || i == 3 || i == 27 || i == 28 || i == 29)
				{
					error = m_com.CanSendOneOnly(0x7DF, cmd, cmdlen);
					Sleep(Common.WAIT_TIME);
					continue;
				}
				else //普通发送命令
				{
					error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmdlen, readbuf, 5003, Common.CMD_MAX_TIME * 2, 3);
					Sleep(50);
					m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
				}
				Sleep(Common.WAIT_TIME);
				//错误处理
				if(error == 5001) //通讯超时
				{
					if(i > 8)
					{
						showProcessList("通讯超时!",Common.NULL,Common.NG);
						break;
					}
					else
						continue;
				}
				else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					if(i > 3)
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						return;
					}
					else
						continue;
				}
				else if(error < 100) //异常回复
				{
					if((readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(readbuf, 0,readbuf[0]+1),Common.NULL,Common.NG);
						break;
					}
				}
				//特殊处理返回结果
				if(i == 32 || i == 33 || i == 34)
				{
					byte [] v_soft = new byte[readbuf[0] - 3];
					System.arraycopy(readbuf, 4, v_soft, 0, readbuf[0] - 3);
					String v_softver = new String(v_soft);
					showProcessList(v_softver,Common.NULL,Common.OK);
					if(t_print == null)
						t_print = new ArrayList<String>();
					t_print.add(step_name + ": " + v_softver);
				}
				else if(readbuf[1] == 0x62) //读数据
				{
					byte [] v_data = new byte[readbuf[0] - 3];
					System.arraycopy(readbuf, 4, v_data, 0, readbuf[0] - 3);
					String v_show = "";
					String v_get = "";
					int v_code = (readbuf[2]&0xFF) * 0x100 + (readbuf[3]&0xFF);
					switch(v_code)
					{
						case 0xF190:
							v_show = new String(v_data);
							v_get = new String(cartype.vin);
							break;
						case 0xF187:
							v_show = new String(v_data);
							v_show = v_show.replace(" ", "");
							v_show = v_show.trim();
							v_get = "";
							break;
						case 0xF18A:
							v_show = new String(v_data);
							v_get = "";
							break;
					}
					v_show = v_show.replace(" ", "");
					v_show = v_show.trim();
					if(v_get.length() > 0)
					{
						showProcessList(v_show,v_get,Common.OK);
					}
					else
					{
						showProcessList(v_show,Common.NULL,Common.NULL);
					}
				}
				else if(i == 11) //结束下载driver
				{
					//showProcessList("",Common.NG);
				}
				else if(i == 18) //结束下载app
				{
					//showProcessList("",Common.NG);
				}
				else if(readbuf[1] == 0x54) //清故障码
				{
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(readbuf[1] == 0x59) //读故障码
				{
					//处理故障码
					byte [] dtc = new byte[256];
					dtc[0] = (byte) (((readbuf[0]&0xFF) - 3) / 4);
					System.arraycopy(readbuf, 4, dtc, 1, readbuf[0] - 3);
					ArrayList<Map<String,String>> dtclist = new ArrayList<Map<String,String>>();
					showProcessList("无故障",Common.NULL,Common.OK);
				}
				else if(readbuf[1] == 0x67 && readbuf[2] == 0x07) //seed
				{
					System.arraycopy(readbuf, 3, seed, 0, readbuf[0] - 2);
				}
				else if(readbuf[1] == 0x74)
				{
					v_maxlen = (readbuf[3]& 0xFF) * 0x100 + (readbuf[4]& 0xFF);
				}
				else if(readbuf[1] == 0x51)
				{
					Sleep(1000);
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(readbuf[1] == 0x71 && readbuf[2] == 0x03 && readbuf[4] == 0x00)
				{
					if(readbuf[5] == 0x03)
					{
						i --;
						Sleep(1000);
					}
					else if(readbuf[5] == 0x02)
					{
						showProcessList("",Common.NULL,Common.OK);
					}
					else
					{
						showProcessList("" + (readbuf[5] & 0xFF),Common.NULL,Common.NG);
						break;
					}
				}
				else if(readbuf[1] == 0x71 && readbuf[2] == 0x01)
				{
					showProcessList( "",Common.NULL,Common.OK);
					Sleep(1000);

				}
				else if(readbuf[1] == 0x51)
				{
					showProcessList("",Common.NULL,Common.OK);
					Sleep(1000);
				}
				else
				{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}
	private void fun_JX65_EmsUP8(Profile.Section Pstep,String Pname)
	{
		int num = Integer.valueOf(Pstep.get("NUM"));
		stepId = Integer.valueOf(Pstep.get("MODULE_ID"));
		String Pmodule = Pstep.get("MODULE");
		String step_t = null;
		String step_name = null;
		byte [] Readbuf = new byte[512];
		byte [] seed = new byte[10];
		byte [] key = new byte[10];
		int v_maxlen = 0;
		short v_crc = (short) 0xFFFF;
		int [] canid = new int[2];
		if (Common.Communication==0) {
			if(!SetCanInitial(Pmodule,canid)) {
				showProcessList("设置通讯盒",Common.NULL, Common.NG);
				return;
			}
			SetCanInitTimer(0);
			SetCanMode(1,500000);
		}else {
			if(!m_com.SetCanBaud(500000))
			{
				showProcessList("设置波特率",Common.NULL,Common.NG);
				return;
			}
			if(!m_com.SetCanMode(2))
			{
				showProcessList("设置CanMode",Common.NULL,Common.NG);
				return;
			}
			if(!m_com.SetCommunTimer(5, 1000, 5000, 0))
			{
				showProcessList("设置时序",Common.NULL,Common.NG);
				return;
			}
			Can can = cartype.getCan(Pstep.get("MODULE"));
			canid[0] = can.getSendid();
			canid[1] = can.getRecvid();
		}
		String emsfile = "";
		String flash_ems = cartype.ems;//*F18-3605010AM*F01R0AD7PX*0x90000000-0x803FFFFF*
		if(flash_ems == null)
		{
			showProcessList("Mes推送数据为空,从本地获取","",Common.NULL);
			flash_ems = Pstep.get("APP");
			//return;
		}
		else
		{
			flash_ems = flash_ems.substring(5);
			int adr = flash_ems.indexOf("FF*");
			if(adr > 0)
			{
				emsfile =flash_ems.substring(adr + 3);
				adr = emsfile.indexOf("*");
				if(adr > 0)
					emsfile = emsfile.substring(0,adr);
			}
			if(emsfile.length() < 5)
			{
				showProcessList("解析EMS文件","解析失败!",Common.NG);
				return;
			}
		}
		SetCanInitTimer(0);
		//先解析刷写数据
		String v_app_file = "";
		byte [] appbuf = null;
		int v_applength = 0;
		int v_down_length = 0;
		int v_app_down = 0;
		//driver
		short v_calc = 0;
		byte [] cmd_link = {0x02,0x3e,(byte) 0x80};
		byte [] cmd_exd = {0x02,0x10,0x03};
		byte [] cmd_stop = {0x02,(byte) 0x85,0x02};
		byte [] cmd_stop1 = {0x03,0x28,0x03,0x03};
		int error = 0;
		for(int i = 1; i < (num + 1); i ++)
		{
			//Pid += 1;
			step_t = Pstep.get("T" + i);
			stepName = Pstep.get("T" + i + "_NAME");
			if(step_t == null) break;
			if(step_t.length() < 3) continue;
			if(step_t.substring(0, 3).equals("CMD"))  //cmd
			{
				//获取cmd长度
				int cmdlen = Commonfunc.HexStringtoInt(step_t.substring(4, 6)) + 1;
				byte [] cmd = new byte[cmdlen];
				if(Commonfunc.CmdStringToBytes(step_t.substring(4), cmd, cmdlen) != cmd.length) return;
				showTip(step_name + "...");
				//---------------------发送前处理---------------------
				//解析下载文件
				if(i == 1)
				{
					v_app_file = cartype.flashDirectory  +  "/EMS/" + emsfile  + ".bin";
					m_com.m_log.PrintLog("App File:" + v_app_file);
					showTip("解析app文件...");
					try {
						//v_applength = Commonfunc.GetHexFileLength(v_app_file, v_app_adr, (long) 0);
						v_applength = Commonfunc.GetBinFileLength(v_app_file);
						appbuf = new byte[v_applength + 10];
						//v_applength = Commonfunc.ReadHexFile(v_app_file, appbuf, v_app_block, (long) 0);
						v_applength = Commonfunc.ReadBinFile(v_app_file, appbuf);
						//v_applength = 0x240000;  //特殊处理
						v_down_length = v_applength;
						//v_calc = Commonfunc.me1781_CalcCRC16(appbuf, 0, v_applength,(short)0xffff);
					} catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					if(v_applength < 100)
					{
						m_com.m_log.PrintLog("Open File Fialed:" + v_app_file);
						showProcessList("App数据解析",v_app_file,Common.NG);
						break;
					}
				}
				else if(cmd[1] == 0x27 && cmd[2] == 0x04) //安全认证
				{
					if((seed[0] | seed[1] | seed[2] | seed[3]) == 0) continue;
					Security.CX62_IMMO_Safekey(seed, key,0);
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				}
				else if(i == 13)  //请求下载
				{
					m_com.CanSendOneOnly(0x7DF, cmd_exd, cmd_exd[0] + 1);
					Sleep(20);
					m_com.CanSendOneOnly(0x7DF, cmd_stop, cmd_stop[0] + 1);
					Sleep(20);
					m_com.CanSendOneOnly(0x7DF, cmd_stop1, cmd_stop1[0] + 1);
					Sleep(20);
				}
				else if(i == 14) //下载数据
				{
					byte [] cmd_down = new byte[v_maxlen + 2];
					int v_len = 0;
					int v_start = 0;
					int v_frame = 1;
					v_app_down = 0;
					while(v_app_down < v_down_length)
					{
						if((v_app_down + v_maxlen - 2) >= v_down_length) //last
						{
							v_len = v_down_length - v_app_down;
						}
						else
						{
							v_len = v_maxlen - 2;
						}
						if((v_len + 2) >= 0x100)
						{
							v_start = 1;
							cmd_down[0] = (byte) ((v_len + 2) / 0x100);
						}
						else
							v_start = 0;
						//拷贝数据
						cmd_down[v_start ++] = (byte) ((v_len + 2) % 0x100);
						cmd_down[v_start ++] = 0x36;
						cmd_down[v_start ++] = (byte)(v_frame ++);
						System.arraycopy(appbuf, v_app_down, cmd_down, v_start, v_len);

						error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd_down,v_len+v_start, Readbuf, 5003, Common.CMD_MAX_TIME * 3, 1);
						if((error > 100) || ((Readbuf[1]&0xFF) == 0x7F))//异常
						{
							break;
						}
						Sleep(5);
						m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
						v_app_down += v_len;
						showTip("下载数据:" + v_applength + "\\" +  v_app_down);
					}
				}


				//特殊处理多次发送命令
				if(i == 14)
				{

				}
				else if(i == 1 || i == 2 || i == 3)
				{
					error = m_com.CanSendOneOnly(0x7DF, cmd, cmdlen);
					Sleep(Common.waittime);
					continue;
				}
				else //普通发送命令
				{
					error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmdlen, Readbuf, 5003, Common.CMD_MAX_TIME * 2, 3);
					Sleep(50);
					m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
				}
				Sleep(Common.waittime);
				//错误处理
				if(error == 5001) //通讯超时
				{
					if(i > 8)
					{
						showProcessList("通讯超时!","",Common.NG);
						break;
					}
					else
						continue;
				}
				else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					if(i > 8 && (i != 22))
					{
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),"",Common.NG);
						return;
					}
					else
						continue;
				}
				else if(error < 100) //异常回复
				{
					if((Readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),"",Common.NG);
						break;
					}
				}
				//特殊处理返回结果
				if(i == 22 || i == 23 || i == 24)
				{
					byte [] v_soft = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf, 4, v_soft, 0, Readbuf[0] - 3);
					String v_softver = new String(v_soft);
					showProcessList(v_softver,"",Common.OK);
					//if(t_printtemp == null)
					//	t_printtemp = new ArrayList<String>();
					//t_printtemp.add(step_name + ": " + v_softver);
				}
				else if(Readbuf[1] == 0x62) //读数据
				{
					byte [] v_data = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf, 4, v_data, 0, Readbuf[0] - 3);
					String v_show = "";
					String v_get = "";
					int v_code = (Readbuf[2]&0xFF) * 0x100 + (Readbuf[3]&0xFF);
					switch(v_code)
					{
						case 0xF190:
							v_show = new String(v_data);
							v_get = new String(cartype.vin);
							break;
						case 0xF187:
							v_show = new String(v_data);
							v_show = v_show.replace(" ", "");
							v_show = v_show.trim();
							v_get = "";
							break;
						case 0xF18A:
							v_show = new String(v_data);
							v_get = "";
							break;
					}
					v_show = v_show.replace(" ", "");
					v_show = v_show.trim();
					if(v_get.length() > 0)
					{
						if(v_show.equals(v_get))
							showProcessList(v_show,"",Common.OK);
						else if(Common.cartype.OptMode == 1)
							showProcessList(v_show,v_get,Common.NULL);
						else
						{
							showProcessList(v_show,v_get,Common.NG);
							break;
						}
					}
					else
					{
						showProcessList(v_show,"",Common.NULL);
					}
				}
				else if(i == 15) //结束下载app
				{
					showProcessList("","",Common.OK);
				}
				else if(Readbuf[1] == 0x54) //清故障码
				{
					showProcessList("","",Common.OK);
				}
				else if(Readbuf[1] == 0x59) //读故障码
				{
					//处理故障码
					byte [] dtc = new byte[256];
					dtc[0] = (byte) (((Readbuf[0]&0xFF) - 3) / 4);
					System.arraycopy(Readbuf, 4, dtc, 1, Readbuf[0] - 3);
					ArrayList<Map<String,String>> dtclist = new ArrayList<Map<String,String>>();
					showProcessList("无故障","",Common.OK);
				}
				else if(Readbuf[1] == 0x67 && Readbuf[2] == 0x03) //seed
				{
					System.arraycopy(Readbuf, 3, seed, 0, Readbuf[0] - 2);
				}
				else if(Readbuf[1] == 0x74)
				{
					v_maxlen = (Readbuf[3]& 0xFF) * 0x100 + (Readbuf[4]& 0xFF);
				}
				else if(Readbuf[1] == 0x51)
				{
					showProcessList("","",Common.OK);
					Sleep(2000);
				}
				else if(Readbuf[1] == 0x71 && Readbuf[2] == 0x03 && Readbuf[4] == 0x00)
				{
					if(Readbuf[5] == 0x03)
					{
						i --;
						Sleep(1000);
					}
					else if(Readbuf[5] == 0x02)
					{
						showProcessList("","",Common.OK);
					}
					else
					{
						showProcessList("" + (Readbuf[5] & 0xFF),"",Common.NG);
						break;
					}
				}
				else if(Readbuf[1] == 0x71 && Readbuf[2] == 0x01)
				{
					showProcessList("","",Common.OK);
					Sleep(1000);
				}
				else
				{
					showProcessList("", "",Common.OK);
				}
			}
		}
	}
	private void fun_JX65_EmsUD8(Profile.Section Pstep,String Pname)
	{
		int num = Integer.valueOf(Pstep.get("NUM"));
		stepId = Integer.valueOf(Pstep.get("MODULE_ID"));
		String Pmodule = Pstep.get("MODULE");
		String step_t = null;
		String step_name = null;
		byte [] Readbuf = new byte[512];
		byte [] seed = new byte[10];
		byte [] key = new byte[10];
		int v_maxlen = 0;
		short v_crc = (short) 0xFFFF;
		int [] canid = new int[2];
		if (Common.Communication==0) {
			if(!SetCanInitial(Pmodule,canid)) {
				showProcessList("设置通讯盒",Common.NULL, Common.NG);
				return;
			}
			SetCanInitTimer(0);
			SetCanMode(1,500000);
		}else {
			if(!m_com.SetCanBaud(500000))
			{
				showProcessList("设置波特率",Common.NULL,Common.NG);
				return;
			}
			if(!m_com.SetCanMode(2))
			{
				showProcessList("设置CanMode",Common.NULL,Common.NG);
				return;
			}
			if(!m_com.SetCommunTimer(5, 1000, 5000, 0))
			{
				showProcessList("设置时序",Common.NULL,Common.NG);
				return;
			}
			Can can = cartype.getCan(Pstep.get("MODULE"));
			canid[0] = can.getSendid();
			canid[1] = can.getRecvid();
		}
		String emsfile = "";
		String flash_ems = cartype.ems;//*F18-3605010AM*F01R0AD7PX*0x90000000-0x803FFFFF*
		if(flash_ems == null)
		{
			showProcessList("Mes推送数据为空,从本地获取","",Common.NULL);
			flash_ems = Pstep.get("APP");
			//return;
		}
		else
		{
			flash_ems = flash_ems.substring(5);
			int adr = flash_ems.indexOf("FF*");
			if(adr > 0)
			{
				emsfile =flash_ems.substring(adr + 3);
				adr = emsfile.indexOf("*");
				if(adr > 0)
					emsfile = emsfile.substring(0,adr);
			}
			if(emsfile.length() < 5)
			{
				showProcessList("解析EMS文件","解析失败!",Common.NG);
				return;
			}
		}
		SetCanInitTimer(0);
		//先解析刷写数据
		String v_app_file = "";
		byte [] appbuf = null;
		int v_applength = 0;
		int v_down_length = 0;
		int v_app_down = 0;
		//driver
		short v_calc = 0;
		byte [] cmd_link = {0x02,0x3e,(byte) 0x80};
		byte [] cmd_exd = {0x02,0x10,0x03};
		byte [] cmd_stop = {0x02,(byte) 0x85,0x02};
		byte [] cmd_stop1 = {0x03,0x28,0x03,0x03};
		int error = 0;
		for(int i = 1; i < (num + 1); i ++)
		{
			//Pid += 1;
			step_t = Pstep.get("T" + i);
			stepName = Pstep.get("T" + i + "_NAME");
			if(step_t == null) break;
			if(step_t.length() < 3) continue;
			if(step_t.substring(0, 3).equals("CMD"))  //cmd
			{
				//获取cmd长度
				int cmdlen = Commonfunc.HexStringtoInt(step_t.substring(4, 6)) + 1;
				byte [] cmd = new byte[cmdlen];
				if(Commonfunc.CmdStringToBytes(step_t.substring(4), cmd, cmdlen) != cmd.length) return;
				showTip(step_name + "...");
				//---------------------发送前处理---------------------
				//解析下载文件
				if(i == 1)
				{
					v_app_file = cartype.flashDirectory +  "EMS/" + emsfile + ".bin";
					m_com.m_log.PrintLog("App File:" + v_app_file);
					showTip("解析app文件...");
					try {
						//v_applength = Commonfunc.GetHexFileLength(v_app_file, v_app_adr, (long) 0);
						v_applength = Commonfunc.GetBinFileLength(v_app_file);
						appbuf = new byte[v_applength + 10];
						//v_applength = Commonfunc.ReadHexFile(v_app_file, appbuf, v_app_block, (long) 0);
						v_applength = Commonfunc.ReadBinFile(v_app_file, appbuf);
						//v_applength = 0x240000;  //特殊处理
						v_down_length = v_applength;
						//v_calc = Commonfunc.me1781_CalcCRC16(appbuf, 0, v_applength,(short)0xffff);
					} catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					if(v_applength < 100)
					{
						m_com.m_log.PrintLog("Open File Fialed:" + v_app_file);
						showProcessList("App数据解析",v_app_file,Common.NG);
						break;
					}
				}
				else if(cmd[1] == 0x27 && cmd[2] == 0x04) //安全认证
				{
					if((seed[0] | seed[1] | seed[2] | seed[3]) == 0) continue;
					Security.CX62_IMMO_Safekey(seed, key,0);
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				}
				else if(i == 13)  //请求下载
				{
					//m_com.CanSendOneOnly(0x7DF, cmd_exd, cmd_exd[0] + 1);
					//Sleep(20);
					//m_com.CanSendOneOnly(0x7DF, cmd_stop, cmd_stop[0] + 1);
					//Sleep(20);
					//m_com.CanSendOneOnly(0x7DF, cmd_stop1, cmd_stop1[0] + 1);
					//Sleep(20);
					cmd[9] = (byte) (v_down_length / 0x10000);
					cmd[10] = (byte) (v_down_length / 0x100);
					cmd[11] = (byte) (v_down_length &0xFF);
				}
				else if(i == 14) //下载数据
				{
					byte [] cmd_down = new byte[v_maxlen + 2];
					int v_len = 0;
					int v_start = 0;
					int v_frame = 1;
					v_app_down = 0;
					while(v_app_down < v_down_length)
					{
						if((v_app_down + v_maxlen - 2) >= v_down_length) //last
						{
							v_len = v_down_length - v_app_down;
						}
						else
						{
							v_len = v_maxlen - 2;
						}
						if((v_len + 2) >= 0x100)
						{
							v_start = 1;
							cmd_down[0] = (byte) ((v_len + 2) / 0x100);
						}
						else
							v_start = 0;
						//拷贝数据
						cmd_down[v_start ++] = (byte) ((v_len + 2) % 0x100);
						cmd_down[v_start ++] = 0x36;
						cmd_down[v_start ++] = (byte)(v_frame ++);
						System.arraycopy(appbuf, v_app_down, cmd_down, v_start, v_len);

						error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd_down,v_len+v_start, Readbuf, 5003, Common.CMD_MAX_TIME * 3, 1);
						if((error > 100) || ((Readbuf[1]&0xFF) == 0x7F))//异常
						{
							break;
						}
						Sleep(5);
						m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
						v_app_down += v_len;
						showTip("下载数据:" + v_applength + "\\" +  v_app_down);
					}
				}


				//特殊处理多次发送命令
				if(i == 14)
				{

				}
				else if(i == 1 || i == 2 || i == 3)
				{
					error = m_com.CanSendOneOnly(0x7DF, cmd, cmdlen);
					Sleep(Common.waittime);
					continue;
				}
				else //普通发送命令
				{
					error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmdlen, Readbuf, 5003, Common.CMD_MAX_TIME * 2, 3);
					Sleep(50);
					m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
				}
				Sleep(Common.waittime);
				//错误处理
				if(error == 5001) //通讯超时
				{
					if(i > 8)
					{
						showProcessList("通讯超时!","",Common.NG);
						break;
					}
					else
						continue;
				}
				else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					if(i > 8 && (i != 22))
					{
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),"",Common.NG);
						return;
					}
					else
						continue;
				}
				else if(error < 100) //异常回复
				{
					if((Readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),"",Common.NG);
						break;
					}
				}
				//特殊处理返回结果
				if(i == 22 || i == 23 || i == 24)
				{
					byte [] v_soft = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf, 4, v_soft, 0, Readbuf[0] - 3);
					String v_softver = new String(v_soft);
					showProcessList(v_softver,"",Common.OK);
					//if(t_printtemp == null)
					//	t_printtemp = new ArrayList<String>();
					//t_printtemp.add(step_name + ": " + v_softver);
				}
				else if(Readbuf[1] == 0x62) //读数据
				{
					byte [] v_data = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf, 4, v_data, 0, Readbuf[0] - 3);
					String v_show = "";
					String v_get = "";
					int v_code = (Readbuf[2]&0xFF) * 0x100 + (Readbuf[3]&0xFF);
					switch(v_code)
					{
						case 0xF190:
							v_show = new String(v_data);
							v_get = new String(Common.cartype.vin);
							break;
						case 0xF187:
							v_show = new String(v_data);
							v_show = v_show.replace(" ", "");
							v_show = v_show.trim();
							v_get = "";
							break;
						case 0xF18A:
							v_show = new String(v_data);
							v_get = "";
							break;
					}
					v_show = v_show.replace(" ", "");
					v_show = v_show.trim();
					if(v_get.length() > 0)
					{
						if(v_show.equals(v_get))
							showProcessList(v_show,"",Common.OK);
						else if(Common.cartype.OptMode == 1)
							showProcessList(v_show,v_get,Common.NULL);
						else
						{
							showProcessList(v_show,v_get,Common.NG);
							break;
						}
					}
					else
					{
						showProcessList(v_show,"",Common.NULL);
					}
				}
				else if(i == 15) //结束下载app
				{
					showProcessList("","",Common.OK);
				}
				else if(Readbuf[1] == 0x54) //清故障码
				{
					showProcessList("","",Common.OK);
				}
				else if(Readbuf[1] == 0x59) //读故障码
				{
					//处理故障码
					byte [] dtc = new byte[256];
					dtc[0] = (byte) (((Readbuf[0]&0xFF) - 3) / 4);
					System.arraycopy(Readbuf, 4, dtc, 1, Readbuf[0] - 3);
					ArrayList<Map<String,String>> dtclist = new ArrayList<Map<String,String>>();
					showProcessList("无故障","",Common.OK);
				}
				else if(Readbuf[1] == 0x67 && Readbuf[2] == 0x03) //seed
				{
					System.arraycopy(Readbuf, 3, seed, 0, Readbuf[0] - 2);
				}
				else if(Readbuf[1] == 0x74)
				{
					v_maxlen = (Readbuf[3]& 0xFF) * 0x100 + (Readbuf[4]& 0xFF);
				}
				else if(Readbuf[1] == 0x51)
				{
					showProcessList("", "",Common.OK);
					Sleep(2000);
				}
				else if(Readbuf[1] == 0x71 && Readbuf[2] == 0x03 && Readbuf[4] == 0x00)
				{
					if(Readbuf[5] == 0x03)
					{
						i --;
						Sleep(1000);
					}
					else if(Readbuf[5] == 0x02)
					{
						showProcessList("","",Common.OK);
					}
					else
					{
						showProcessList("" + (Readbuf[5] & 0xFF),"",Common.NG);
						break;
					}
				}
				else if(Readbuf[1] == 0x71 && Readbuf[2] == 0x01)
				{
					showProcessList( "","",Common.OK);
					Sleep(1000);
				}
				else
				{
					showProcessList("", "",Common.OK);
				}
			}
		}
	}
	private void fun_PHEV_TcuFlash(Section Pstep,String Pname)
	{
		int num = Integer.valueOf(Pstep.get("NUM"));
		int Pid = Integer.valueOf(Pstep.get("MODULE_ID"));
		String Pmodule = Pstep.get("MODULE");
		String step_t = null;
		String step_name = null;
		byte [] Readbuf = new byte[512];
		byte [] seed = new byte[4];
		byte [] key = new byte[4];
		int v_maxlen = 0;
		short v_crc = (short) 0xFFFF;
		if (Common.Communication==0) {
			if(!SetCanInitial(Pstep.get("MODULE"),canid)) {
				showProcessList("设置通讯盒",Common.NULL, Common.NG);
				return;
			}
			SetCanInitTimer(0);
			SetCanMode(1,500000);
		}else {
			if(!m_com.SetCanBaud(500000))
			{
				showProcessList("设置波特率",Common.NULL,Common.NG);
				return;
			}
			if(!m_com.SetCanMode(2))
			{
				showProcessList("设置CanMode",Common.NULL,Common.NG);
				return;
			}
			if(!m_com.SetCommunTimer(5, 1000, 5000, 0))
			{
				showProcessList("设置时序",Common.NULL,Common.NG);
				return;
			}
			Can can = cartype.getCan(Pstep.get("MODULE"));
			canid[0] = can.getSendid();
			canid[1] = can.getRecvid();
		}

		//先解析刷写数据
		String v_app_file = "";
		String v_dri_file = "";
		byte [] appbuf = null;
		//int v_applen = 0;
		byte [] dribuf = null;
		//int v_drilen = 0;
		byte [] v_dri_adr = new byte[256];
		byte [] v_dri_len = new byte[4];
		int [] v_dri_block = new int[10];
		int v_drilength = 0;
		byte [] v_app_adr = new byte[512];
		byte [] v_app_len = new byte[4];
		int [] v_app_block = new int[100];
		int v_applength = 0;
		int v_down_block = 0; //已经下载的块数
		int v_down_length = 0;
		int v_app_down = 0;
		//driver
		int v_dri_down_block = 0;
		int v_dri_down_length = 0;
		int v_dri_down = 0;
		byte [] cmd_link = {0x02,0x3e,(byte) 0x80};
		int error = 0;
		String tcu_name = "";
		String tcu_driver = "";
		tcu_name = CommonXml.GetEcuFlashName(cartype.mesinfo, "TCU_FLASH");
		if(tcu_name == null||("").equals(tcu_name))
			tcu_name = Pstep.get("FILE");
		tcu_driver =Pstep.get("DRIVER");
		if(tcu_name == null)
		{
			showProcessList("获取文件信息失败!",Common.NULL,Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++)
		{
			Pid += 1;
			step_t = Pstep.get("T" + i);
			stepName = Pstep.get("T" + i + "_NAME");
			if(step_t == null) break;
			if(step_t.length() < 3) continue;
			if(step_t.substring(0, 3).equals("CMD"))  //cmd
			{
				//获取cmd长度
				int cmdlen = Commonfunc.hexStringtoInt(step_t.substring(4, 6)) + 1;
				byte [] cmd = new byte[cmdlen];
				if(Commonfunc.CmdStringToBytes(step_t.substring(4), cmd, cmdlen) != cmd.length) return;
				showTip(stepName + "...");
				//---------------------发送前处理---------------------
				//解析下载文件
				if(i == 5)
				{
					//先解析driver文件
					showTip("解析Driver文件...");
					if (tcu_driver.length()>5) v_dri_file =cartype.carDirectory+"TCU/"+tcu_driver;
					v_app_file = cartype.carDirectory+  "TCU/" + tcu_name;
					if((v_dri_file != null) &&v_dri_file.length() > 5)
					{
						if(".bin".equals(v_dri_file.substring(v_dri_file.length() - 4)) )
						{
							try {
								v_drilength = Commonfunc.GetBinFileLength(v_dri_file);
								dribuf = new byte[v_drilength + 10];
								v_drilength = Commonfunc.ReadBinFile(v_dri_file, dribuf);
								v_dri_down_length=v_drilength;
							} catch (IOException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
								v_drilength = 0;
								showProcessList("解析Driver文件" + v_dri_file,Common.NULL,Common.NG);
								break;
							}
							if(v_drilength <= 10)
							{
								showProcessList("Driver数据解析" + v_dri_file,Common.NULL,Common.NG);
								break;
							}
						}
					}
					showTip("解析app文件...");

					if((v_app_file != null) && (v_app_file.length() > 5))
					{
						if(".bin".equals(v_app_file.substring(v_app_file.length() - 4)) || ".BIN".equals(v_app_file.substring(v_app_file.length() - 4)))
						{
							try {
								v_applength = Commonfunc.GetBinFileLength(v_app_file);
								appbuf = new byte[v_applength + 10];
								v_applength = Commonfunc.ReadBinFile(v_app_file, appbuf);
								v_down_length=v_applength;
							} catch (IOException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
								showProcessList("解析app文件" + v_app_file,Common.NULL,Common.NG);
								break;
							}
						}
						if(v_applength < 100)
						{
							showProcessList("App数据解析失败" + v_app_file,Common.NULL,Common.NG);
							break;
						}
					}
				}
				else if(cmd[1] == 0x27 && cmd[2] == 0x04) //安全认证
				{
					if((seed[0] | seed[1] | seed[2] | seed[3]) == 0) continue;
					//EolFunction.Changan_SafeCode_level(seed,key,0x61E47D07);
//					Security.CX62B_TCM_Safekey(seed, key);
					Security.Chery_Standard_Safekey(seed,key);
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				}
				else if(cmd[1] == 0x2E) //写
				{
					int v_code = (cmd[2]&0xFF) * 0x100 + (cmd[3]&0xFF);
					switch(v_code)
					{
						case 0xF199:
							System.arraycopy(cartype.time, 0, cmd, 4, cmd[0] - 3);
							break;
					}
				}
//				else if(i == 15) //开始下载驱动  固定长度，不计算
//				{
//					if(v_drilength < 10) //无需下载驱动
//					{
//						i += 3;
//						continue;
//					}
//					else //下载驱动,驱动暂时按单块处理,FLR也是多块
//					{
//						if(v_dri_down_block < v_dri_block[0])
//						{
//							System.arraycopy(v_dri_adr, 1 + 4 * v_dri_down_block, cmd, 4, 4);
//							v_dri_len[0] = (byte) ((v_dri_block[1 + v_dri_down_block] >>> 24) & 0xFF);
//							v_dri_len[1] = (byte) ((v_dri_block[1 + v_dri_down_block] >>> 16) & 0xFF);
//							v_dri_len[2] = (byte) ((v_dri_block[1 + v_dri_down_block] >>> 8) & 0xFF);
//							v_dri_len[3] = (byte) ((v_dri_block[1 + v_dri_down_block] >>> 0) & 0xFF);
//							v_dri_down_length += v_dri_block[1 + v_dri_down_block];
//							System.arraycopy(v_dri_len, 0, cmd, 8, 4);
//						}
//					}
//				}
				else if(i == 16) //下载驱动
				{
					byte [] cmd_down = new byte[v_maxlen + 2];
					int v_len = 0;
					int v_start = 0;
					int v_frame = 1;
					while(v_dri_down < v_dri_down_length)
					{
						if((v_dri_down + v_maxlen - 2) >= v_dri_down_length) //last
						{
							v_len = v_dri_down_length - v_dri_down;
						}
						else
						{
							v_len = v_maxlen - 2;
						}
						if((v_len + 2) >= 0x100)
						{
							v_start = 1;
							cmd_down[0] = (byte) ((v_len + 2) / 0x100);
						}
						else
							v_start = 0;
						//拷贝数据
						cmd_down[v_start ++] = (byte) ((v_len + 2) % 0x100);
						cmd_down[v_start ++] = 0x36;
						cmd_down[v_start ++] = (byte)(v_frame ++);
						System.arraycopy(dribuf, v_dri_down, cmd_down, v_start, v_len);

						error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd_down,v_len+v_start, Readbuf, 5003, Common.CMD_MAX_TIME * 3, 1);
						if((error > 100) || ((Readbuf[1]&0xFF) == 0x7F))//异常
						{
							break;
						}
						Sleep(5);
						m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
						v_dri_down += v_len;
						showTip("下载数据:" + v_drilength + "\\" +  v_dri_down);
					}
					v_dri_down_block ++;
				}
//				else if(i == 18) //检查有效性
//				{
//					System.arraycopy(v_dri_adr, 1, cmd, 5, 4);
//				}
//				else if(i == 20) //擦除APP,按多个块处理
//				{
//					System.arraycopy(v_app_adr, 1 + 4 * v_down_block, cmd, 5, 4);
//					v_app_len[0] = 0x00;
//					v_app_len[1] = 0x3C;
//					v_app_len[2] = 0x00;
//					v_app_len[3] = 0x00;
//					System.arraycopy(v_app_len, 0, cmd, 9, 4);
//				}
//				else if(i == 21) //请求下载APP
//				{
//					System.arraycopy(v_app_adr, 1 + 4 * v_down_block, cmd, 4, 4);
//					v_app_len[0] = (byte) ((v_applength >>> 24)&0xFF);
//					v_app_len[1] = (byte) ((v_applength >>> 16)&0xFF);
//					v_app_len[2] = (byte) ((v_applength >>> 8)&0xFF);
//					v_app_len[3] = (byte) ((v_applength >>> 0)&0xFF);
//					System.arraycopy(v_app_len, 0, cmd, 8, 4);
//					v_down_length = v_applength;
//				}
				else if(i == 22) //下载数据
				{
					byte [] cmd_down = new byte[v_maxlen + 2];
					int v_len = 0;
					int v_start = 0;
					int v_frame = 1;
					while(v_app_down < v_down_length)
					{
						if((v_app_down + v_maxlen - 2) >= v_down_length) //last
						{
							v_len = v_down_length - v_app_down;
						}
						else
						{
							v_len = v_maxlen - 2;
						}
						if((v_len + 2) >= 0x100)
						{
							v_start = 1;
							cmd_down[0] = (byte) ((v_len + 2) / 0x100);
						}
						else
							v_start = 0;
						//拷贝数据
						cmd_down[v_start ++] = (byte) ((v_len + 2) % 0x100);
						cmd_down[v_start ++] = 0x36;
						cmd_down[v_start ++] = (byte)(v_frame ++);
						System.arraycopy(appbuf, v_app_down, cmd_down, v_start, v_len);

						error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd_down,v_len+v_start, Readbuf, 5003, Common.CMD_MAX_TIME * 3, 1);
						if((error > 100) || ((Readbuf[1]&0xFF) == 0x7F))//异常
						{
							break;
						}
						Sleep(5);
						m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
						v_app_down += v_len;
						showTip("下载数据:" + v_applength + "\\" +  v_app_down);
					}
					v_down_block ++;
				}

				//特殊处理多次发送命令
				if(i == 16 || i == 22)
				{

				}
				else if(i == 5 || i == 6 || i == 7 || i == 28 || i == 29 || i == 30)
				{
					error = m_com.CanSendOneOnly(0x7DF, cmd, cmdlen);
					Sleep(Common.WAIT_TIME);
					continue;
				}
				else //普通发送命令
				{
					error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmdlen, Readbuf, 5003, Common.CMD_MAX_TIME * 2, 2);
					Sleep(50);
					if (i!=10){
						m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
					}
				}
				Sleep(Common.WAIT_TIME);
				//错误处理
				if(error == 5001) //通讯超时
				{
					if(i > 10)
					{
						showProcessList("通讯超时!",Common.NULL,Common.NG);
						break;
					}
					else
						continue;
				}
				else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					if(i > 10)
					{
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
						return;
					}
					else
						continue;
				}
				else if(error < 100) //异常回复
				{
					if((Readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
						break;
					}
				}
				//特殊处理返回结果
				if(i == 33 || i == 34 || i == 35)
				{
					byte [] v_soft = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf, 4, v_soft, 0, Readbuf[0] - 3);
					String v_softver = new String(v_soft);
					showProcessList(v_softver,Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x62) //读数据
				{
					byte [] v_data = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf, 4, v_data, 0, Readbuf[0] - 3);
					String v_show = "";
					String v_get = "";
					int v_code = (Readbuf[2]&0xFF) * 0x100 + (Readbuf[3]&0xFF);
					switch(v_code)
					{
						case 0xF190:
							v_show = new String(v_data);
							v_get = new String(cartype.vin);
							break;
						case 0xF187:
							v_show = new String(v_data);
							v_show = v_show.replace(" ", "");
							v_show = v_show.trim();
							v_get = "";
							break;
						case 0xF18A:
							v_show = new String(v_data);
							v_get = "";
							break;
					}
					v_show = v_show.replace(" ", "");
					v_show = v_show.trim();
					if(v_get.length() > 0)
					{
						if(v_show.equals(v_get))
							showProcessList(v_show,v_get,Common.OK);
						else
						{
							showProcessList(v_show ,v_get,Common.NG);
							break;
						}
					}
					else
					{
						showProcessList(v_show,Common.NULL,Common.NULL);
					}
				}
				else if(i == 17) //结束下载driver
				{
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(i == 23) //结束下载app
				{
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x54) //清故障码
				{
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x59) //读故障码
				{
					//处理故障码
					byte [] dtc = new byte[256];
					dtc[0] = (byte) (((Readbuf[0]&0xFF) - 3) / 4);
					System.arraycopy(Readbuf, 4, dtc, 1, Readbuf[0] - 3);
					ArrayList<Map<String,String>> dtclist = new ArrayList<Map<String,String>>();
					showProcessList("无故障",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x67 && Readbuf[2] == 0x03) //seed
				{
					System.arraycopy(Readbuf, 3, seed, 0, Readbuf[0] - 2);
				}
				else if(Readbuf[1] == 0x74)
				{
					v_maxlen = (Readbuf[3]& 0xFF) * 0x100 + (Readbuf[4]& 0xFF);
				}
				else if(Readbuf[1] == 0x51)
				{
					Sleep(1000);
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x71 && Readbuf[2] == 0x03 && Readbuf[4] == 0x00)
				{
					if(Readbuf[5] == 0x03)
					{
						i --;
						Sleep(1000);
					}
					else if(Readbuf[5] == 0x02)
					{
						showProcessList("",Common.NULL,Common.OK);
					}
					else
					{
						showProcessList("" + (Readbuf[5] & 0xFF),Common.NULL,Common.OK);
						break;
					}
				}
				else if(readbuf[1]==0x51){//复位
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				}
				else if(Readbuf[1] == 0x71 && Readbuf[2] == 0x01)
				{
					showProcessList("",Common.NULL,Common.OK);
					Sleep(1000);
				}
				else
				{
					showProcessList( "",Common.NULL,Common.OK);
				}
			}
		}
	}
	private void fun_T1NPHEV_TcuFlash(Section Pstep,String Pname)
	{
		int num = Integer.valueOf(Pstep.get("NUM"));
		int Pid = Integer.valueOf(Pstep.get("MODULE_ID"));
		String Pmodule = Pstep.get("MODULE");
		String step_t = null;
		String step_name = null;
		byte [] Readbuf = new byte[512];
		byte [] seed = new byte[4];
		byte [] key = new byte[4];
		int v_maxlen = 0;
		short v_crc = (short) 0xFFFF;
		if (Common.Communication==0) {
			if(!SetCanInitial(Pstep.get("MODULE"),canid)) {
				showProcessList("设置通讯盒",Common.NULL, Common.NG);
				return;
			}
			SetCanInitTimer(0);
			SetCanMode(1,500000);
		}else {
			if(!m_com.SetCanBaud(500000))
			{
				showProcessList("设置波特率",Common.NULL,Common.NG);
				return;
			}
			if(!m_com.SetCanMode(2))
			{
				showProcessList("设置CanMode",Common.NULL,Common.NG);
				return;
			}
			if(!m_com.SetCommunTimer(5, 1000, 5000, 0))
			{
				showProcessList("设置时序",Common.NULL,Common.NG);
				return;
			}
			Can can = cartype.getCan(Pstep.get("MODULE"));
			canid[0] = can.getSendid();
			canid[1] = can.getRecvid();
		}

		//先解析刷写数据
		String v_app_file = "";
		String v_dri_file = "";
		byte [] appbuf = null;
		//int v_applen = 0;
		byte [] dribuf = null;
		//int v_drilen = 0;
		byte [] v_dri_adr = new byte[256];
		byte [] v_dri_len = new byte[4];
		int [] v_dri_block = new int[10];
		int v_drilength = 0;
		byte [] v_app_adr = new byte[512];
		byte [] v_app_len = new byte[4];
		int [] v_app_block = new int[100];
		int v_applength = 0;
		int v_down_block = 0; //已经下载的块数
		int v_down_length = 0;
		int v_app_down = 0;
		//driver
		int v_dri_down_block = 0;
		int v_dri_down_length = 0;
		int v_dri_down = 0;
		byte [] cmd_link = {0x02,0x3e,(byte) 0x80};
		int error = 0;
		String tcu_name = "";
		String tcu_driver = "";
		short appcrc = 0;
		tcu_name = CommonXml.GetEcuFlashName(cartype.mesinfo, "TCU_FLASH");
		if(tcu_name == null||("").equals(tcu_name))
			tcu_name = Pstep.get("FILE");
			tcu_driver =Pstep.get("DRIVER");
		if(tcu_name == null)
		{
			showProcessList("获取文件信息失败!",Common.NULL,Common.NG);
			return;
		}
		for(int i = 1; i < (num + 1); i ++)
		{
			Pid += 1;
			step_t = Pstep.get("T" + i);
			stepName = Pstep.get("T" + i + "_NAME");
			if(step_t == null) break;
			if(step_t.length() < 3) continue;
			if(step_t.substring(0, 3).equals("CMD"))  //cmd
			{
				//获取cmd长度
				int cmdlen = Commonfunc.hexStringtoInt(step_t.substring(4, 6)) + 1;
				byte [] cmd = new byte[cmdlen];
				if(Commonfunc.CmdStringToBytes(step_t.substring(4), cmd, cmdlen) != cmd.length) return;
				showTip(stepName + "...");
				//---------------------发送前处理---------------------
				//解析下载文件
				if(i == 5)
				{
					//先解析driver文件
					showTip("解析Driver文件...");
					if (tcu_driver.length()>5) v_dri_file =cartype.carDirectory+"TCU/"+tcu_driver;
					v_app_file = cartype.carDirectory+  "TCU/" + tcu_name;
					if((v_dri_file != null) &&v_dri_file.length() > 5)
					{
						if(".bin".equals(v_dri_file.substring(v_dri_file.length() - 4)) )
						{
							try {
								v_drilength = Commonfunc.GetBinFileLength(v_dri_file);
								dribuf = new byte[v_drilength + 10];
								v_drilength = Commonfunc.ReadBinFile(v_dri_file, dribuf);
								v_dri_down_length=v_drilength;
								} catch (IOException e) {
									// TODO Auto-generated catch block
									e.printStackTrace();
									v_drilength = 0;
									showProcessList("解析Driver文件" + v_dri_file,Common.NULL,Common.NG);
									break;
								}
							if(v_drilength <= 10)
							{
								showProcessList("Driver数据解析" + v_dri_file,Common.NULL,Common.NG);
								break;
							}
						}
					}
					showTip("解析app文件...");

					if((v_app_file != null) && (v_app_file.length() > 5))
					{
						if(".bin".equals(v_app_file.substring(v_app_file.length() - 4)) || ".BIN".equals(v_app_file.substring(v_app_file.length() - 4)))
						{
							try {
								v_applength = Commonfunc.GetBinFileLength(v_app_file);
								appbuf = new byte[v_applength + 10];
								v_applength = Commonfunc.ReadBinFile(v_app_file, appbuf);
								appcrc = Commonfunc.me1781_CalcCRC16(appbuf,0,v_applength, (short) 0xffff);
								v_down_length=v_applength;
							} catch (IOException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
								showProcessList("解析app文件" + v_app_file,Common.NULL,Common.NG);
								break;
							}
						}
						if(v_applength < 100)
						{
							showProcessList("App数据解析失败" + v_app_file,Common.NULL,Common.NG);
							break;
						}
					}
				}
				else if(cmd[1] == 0x27 && cmd[2] == 0x04) //安全认证
				{
					if((seed[0] | seed[1] | seed[2] | seed[3]) == 0) continue;
					//EolFunction.Changan_SafeCode_level(seed,key,0x61E47D07);
//					Security.CX62B_TCM_Safekey(seed, key);
					Security.Chery_Standard_Safekey(seed,key);
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				}
				else if(cmd[1] == 0x2E) //写
				{
					int v_code = (cmd[2]&0xFF) * 0x100 + (cmd[3]&0xFF);
					switch(v_code)
					{
						case 0xF199:
							System.arraycopy(cartype.time, 0, cmd, 4, cmd[0] - 3);
							break;
					}
				}
				else if(i == 15) //下载驱动
				{
					byte [] cmd_down = new byte[v_maxlen + 2];
					int v_len = 0;
					int v_start = 0;
					int v_frame = 1;
					while(v_dri_down < v_dri_down_length)
					{
						if((v_dri_down + v_maxlen - 2) >= v_dri_down_length) //last
						{
							v_len = v_dri_down_length - v_dri_down;
						}
						else
						{
							v_len = v_maxlen - 2;
						}
						if((v_len + 2) >= 0x100)
						{
							v_start = 1;
							cmd_down[0] = (byte) ((v_len + 2) / 0x100);
						}
						else
							v_start = 0;
						//拷贝数据
						cmd_down[v_start ++] = (byte) ((v_len + 2) % 0x100);
						cmd_down[v_start ++] = 0x36;
						cmd_down[v_start ++] = (byte)(v_frame ++);
						System.arraycopy(dribuf, v_dri_down, cmd_down, v_start, v_len);

						error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd_down,v_len+v_start, Readbuf, 5003, Common.CMD_MAX_TIME * 3, 1);
						if((error > 100) || ((Readbuf[1]&0xFF) == 0x7F))//异常
						{
							break;
						}
						Sleep(5);
						m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
						v_dri_down += v_len;
						showTip("下载数据:" + v_drilength + "\\" +  v_dri_down);
					}
					v_dri_down_block ++;
				}
				else if(i == 21) //下载数据
				{
					byte [] cmd_down = new byte[v_maxlen + 2];
					int v_len = 0;
					int v_start = 0;
					int v_frame = 1;
					while(v_app_down < v_down_length)
					{
						if((v_app_down + v_maxlen - 2) >= v_down_length) //last
						{
							v_len = v_down_length - v_app_down;
						}
						else
						{
							v_len = v_maxlen - 2;
						}
						if((v_len + 2) >= 0x100)
						{
							v_start = 1;
							cmd_down[0] = (byte) ((v_len + 2) / 0x100);
						}
						else
							v_start = 0;
						//拷贝数据
						cmd_down[v_start ++] = (byte) ((v_len + 2) % 0x100);
						cmd_down[v_start ++] = 0x36;
						cmd_down[v_start ++] = (byte)(v_frame ++);
						System.arraycopy(appbuf, v_app_down, cmd_down, v_start, v_len);

						error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd_down,v_len+v_start, Readbuf, 5003, Common.CMD_MAX_TIME * 3, 1);
						if((error > 100) || ((Readbuf[1]&0xFF) == 0x7F))//异常
						{
							break;
						}
						Sleep(5);
						m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
						v_app_down += v_len;
						showTip("下载数据:" + v_applength + "\\" +  v_app_down);
					}
					v_down_block ++;
				}
				else if(i == 23)
				{
					cmd[cmd[0] - 1] = (byte) (appcrc / 0x100);
					cmd[cmd[0]] = (byte) (appcrc % 0x100);
				}

				//特殊处理多次发送命令
				if(i == 15 || i == 21)
				{

				}
				else if(i == 5 || i == 6 || i == 7 || i == 30 || i == 31 || i == 32)
				{
					error = m_com.CanSendOneOnly(0x7DF, cmd, cmdlen);
					Sleep(Common.WAIT_TIME);
					continue;
				}
				else //普通发送命令
				{
					error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmdlen, Readbuf, 5003, Common.CMD_MAX_TIME * 2, 2);
					Sleep(50);
					if (i!=10){
						m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
					}
				}
				Sleep(Common.WAIT_TIME);
				//错误处理
				if(error == 5001) //通讯超时
				{
					if(i > 10)
					{
						showProcessList("通讯超时!",Common.NULL,Common.NG);
						break;
					}
					else
						continue;
				}
				else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					if(i > 10)
					{
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
						return;
					}
					else
						continue;
				}
				else if(error < 100) //异常回复
				{
					if((Readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
						break;
					}
				}
				//特殊处理返回结果
				if(i == 34 || i == 35 || i == 36)
				{
					byte [] v_soft = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf, 4, v_soft, 0, Readbuf[0] - 3);
					String v_softver = new String(v_soft);
					showProcessList(v_softver,Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x62) //读数据
				{
					byte [] v_data = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf, 4, v_data, 0, Readbuf[0] - 3);
					String v_show = "";
					String v_get = "";
					int v_code = (Readbuf[2]&0xFF) * 0x100 + (Readbuf[3]&0xFF);
					switch(v_code)
					{
						case 0xF190:
							v_show = new String(v_data);
							v_get = new String(cartype.vin);
							break;
						case 0xF187:
							v_show = new String(v_data);
							v_show = v_show.replace(" ", "");
							v_show = v_show.trim();
							v_get = "";
							break;
						case 0xF18A:
							v_show = new String(v_data);
							v_get = "";
							break;
					}
					v_show = v_show.replace(" ", "");
					v_show = v_show.trim();
					if(v_get.length() > 0)
					{
						if(v_show.equals(v_get))
							showProcessList(v_show,v_get,Common.OK);
						else
						{
							showProcessList(v_show ,v_get,Common.NG);
							break;
						}
					}
					else
					{
						showProcessList(v_show,Common.NULL,Common.NULL);
					}
				}
				else if(i == 16) //结束下载driver
				{
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(i == 22) //结束下载app
				{
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x54) //清故障码
				{
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x59) //读故障码
				{
					//处理故障码
					byte [] dtc = new byte[256];
					dtc[0] = (byte) (((Readbuf[0]&0xFF) - 3) / 4);
					System.arraycopy(Readbuf, 4, dtc, 1, Readbuf[0] - 3);
					ArrayList<Map<String,String>> dtclist = new ArrayList<Map<String,String>>();
					showProcessList("无故障",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x67 && Readbuf[2] == 0x03) //seed
				{
					System.arraycopy(Readbuf, 3, seed, 0, Readbuf[0] - 2);
				}
				else if(Readbuf[1] == 0x74)
				{
					v_maxlen = (Readbuf[3]& 0xFF) * 0x100 + (Readbuf[4]& 0xFF);
				}
				else if(Readbuf[1] == 0x51)
				{
					Sleep(1000);
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x71)
				{
					if(Readbuf[2] == 0x01)
					{
						Sleep(1000);
						showProcessList("",Common.NULL,Common.OK);
					}
					else if(Readbuf[2] == 0x02) //结束
					{
						showProcessList("",Common.NULL,Common.OK);
					}
					else
					{
						if(Readbuf[5] == 0x03)
						{
							i --;
							Sleep(1000);
						}
						else if(Readbuf[5] == 0x02)
						{
							showProcessList("",Common.NULL,Common.OK);
						}
						else
						{
							showProcessList("" + (Readbuf[5] & 0xFF),Common.NULL,Common.OK);
							break;
						}
					}
				}
				else if(readbuf[1]==0x51){//复位
					showProcessList("",Common.NULL,Common.OK);
					Commonfunc.sleep(1900);
				}
				else if(Readbuf[1] == 0x71 && Readbuf[2] == 0x01)
				{
					showProcessList("",Common.NULL,Common.OK);
					Sleep(1000);
				}
				else
				{
					showProcessList( "",Common.NULL,Common.OK);
				}
			}
		}
	}

	private void fun_JX65_Ems1781(Section Pstep,String Pname)
	{
		int num = Integer.valueOf(Pstep.get("NUM"));
		int Pid = Integer.valueOf(Pstep.get("MODULE_ID"));
		String Pmodule = Pstep.get("MODULE");
		String step_t = null;
		String step_name = null;
		byte [] Readbuf = new byte[512];
		byte [] seed = new byte[10];
		byte [] key = new byte[10];
		int v_maxlen = 0;
		short v_crc = (short) 0xFFFF;
		int [] canid = new int[2];
		if (Common.Communication==0) {
			if(!SetCanInitial(Pmodule,canid)) {
				showProcessList("设置通讯盒",Common.NULL, Common.NG);
				return;
			}
			SetCanInitTimer(0);
			SetCanMode(1,500000);
		}else {
			if(!m_com.SetCanBaud(500000))
			{
				showProcessList("设置波特率",Common.NULL,Common.NG);
				return;
			}
			if(!m_com.SetCanMode(2))
			{
				showProcessList("设置CanMode",Common.NULL,Common.NG);
				return;
			}
			if(!m_com.SetCommunTimer(5, 1000, 5000, 0))
			{
				showProcessList("设置时序",Common.NULL,Common.NG);
				return;
			}
			Can can = cartype.getCan(Pstep.get("MODULE"));
			canid[0] = can.getSendid();
			canid[1] = can.getRecvid();
		}
		String flash_ems = cartype.ems;/*"*F16-3605010CA*800400008027FFFF*F01R0AD4WU*F01R0AD4WU/flashdriver.hex*";*/
		if(flash_ems == null)
		{
			showProcessList("Mes推送数据为空",Common.NULL,Common.NG);
			flash_ems = Pstep.get("APP");
			//return;
		}
		//SetCanInitTimer(0);
		//先解析刷写数据
		String v_app_file = "";
		String v_dri_file = "";
		byte [] appbuf = null;
		//int v_applen = 0;
		byte [] dribuf = null;
		//int v_drilen = 0;
		int v_drilength = 0;
		int v_applength = 0;
		int v_down_length = 0;
		int v_app_down = 0;
		int v_down_block = 0; //已经下载的块数
		//driver
		short v_calc = 0;
		byte [] cmd_link = {0x02,0x3e,(byte) 0x80};
		int error = 0;
		for(int i = 1; i < (num + 1); i ++)
		{
			//Pid += 1;
			stepId = Pid + i;
			step_t = Pstep.get("T" + i);
			stepName  = Pstep.get("T" + i + "_NAME");
			if(step_t == null) break;
			if(step_t.length() < 3) continue;
			if(step_t.substring(0, 3).equals("CMD"))  //cmd
			{
				//获取cmd长度
				int cmdlen = Commonfunc.hexStringtoInt(step_t.substring(4, 6)) + 1;
				byte [] cmd = new byte[cmdlen];
				if(Commonfunc.CmdStringToBytes(step_t.substring(4), cmd, cmdlen) != cmd.length) return;
				showTip(step_name + "...");
				//---------------------发送前处理---------------------
				//解析下载文件
				if(i == 1)
				{
					//先解析driver文件
					showTip("解析Driver文件...");
					if(flash_ems == null)
					{
						showProcessList("Mes推送数据为空",Common.NULL,Common.NG);
						return;
					}
					else
					{
						v_dri_file = cartype.flashDirectory +  "/EMS/" +  "flashdrive.bin";
						int ems_a = flash_ems.indexOf("*", 20);
						if(ems_a > 0)
						{
							int ems_b = flash_ems.indexOf("*", ems_a + 2);
							String ems_name = flash_ems.substring(ems_a + 1, ems_b);
							v_app_file = cartype.flashDirectory  +  "/EMS/" + ems_name  + ".bin";
						}
						else //本地获取
						{
							v_app_file = cartype.flashDirectory  +  "/EMS/" + flash_ems;
						}
					}
					if((v_dri_file != null) && (v_dri_file.length() > 15))
					{
						try {
							v_drilength  = Commonfunc.GetBinFileLength(v_dri_file);
							//v_drilength = Commonfunc.GetHexFileLength(v_dri_file, v_dri_adr, (long) 0);;
							dribuf = new byte[v_drilength + 10];
							//v_drilength = Commonfunc.ReadHexFile(v_dri_file,dribuf, v_dri_block, (long) 0);
							v_drilength = Commonfunc.ReadBinFile(v_dri_file, dribuf);
						} catch (IOException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
						if(v_drilength != 16)
						{
							m_com.m_log.PrintLog("Open File Fialed:" + v_dri_file);
							showProcessList("Driver数据解析:" + v_dri_file,Common.NULL,Common.NG);
							break;
						}
					}
					showTip("解析app文件...");
					try {
						//v_applength = Commonfunc.GetHexFileLength(v_app_file, v_app_adr, (long) 0);
						v_applength = Commonfunc.GetBinFileLength(v_app_file);
						appbuf = new byte[v_applength + 10];
						//v_applength = Commonfunc.ReadHexFile(v_app_file, appbuf, v_app_block, (long) 0);
						v_applength = Commonfunc.ReadBinFile(v_app_file, appbuf);
						//v_applength = 0x240000;  //特殊处理
						v_down_length = v_applength;
						v_calc = Commonfunc.me1781_CalcCRC16(appbuf, 0, v_applength,(short)0xffff);
					} catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					if(v_applength < 100)
					{
						m_com.m_log.PrintLog("Open File Fialed:" + v_app_file);
						showProcessList("App数据解析:" + v_app_file,Common.NULL,Common.NG);
						break;
					}
					else
						showProcessList("App数据解析:" + v_app_file,Common.NULL,Common.OK);
				}
				else if(cmd[1] == 0x27 && cmd[2] == 0x04) //安全认证
				{
					if((seed[0] | seed[1] | seed[2] | seed[3]) == 0) continue;
					//EolFunction.Changan_SafeCode_level(seed,key,0x61E47D07);
					Security.CX62_IMMO_Safekey(seed, key,0);
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				}
				else if(cmd[1] == 0x2E) //写
				{
					int v_code = (cmd[2]&0xFF) * 0x100 + (cmd[3]&0xFF);
					switch(v_code)
					{
						case 0xF199:
							System.arraycopy(cartype.time, 0, cmd, 4, cmd[0] - 3);
							break;
					}
				}
				else if(i == 8) //下载驱动
				{
					//拷贝数据
					System.arraycopy(dribuf, 0, cmd, 3, v_drilength);
				}
				else if(i == 14) //下载数据
				{
					byte [] cmd_down = new byte[v_maxlen + 2];
					int v_len = 0;
					int v_start = 0;
					int v_frame = 1;
					v_app_down = 0;
					while(v_app_down < v_down_length)
					{
						if((v_app_down + v_maxlen - 2) >= v_down_length) //last
						{
							v_len = v_down_length - v_app_down;
						}
						else
						{
							v_len = v_maxlen - 2;
						}
						if((v_len + 2) >= 0x100)
						{
							v_start = 1;
							cmd_down[0] = (byte) ((v_len + 2) / 0x100);
						}
						else
							v_start = 0;
						//拷贝数据
						cmd_down[v_start ++] = (byte) ((v_len + 2) % 0x100);
						cmd_down[v_start ++] = 0x36;
						cmd_down[v_start ++] = (byte)(v_frame ++);
						System.arraycopy(appbuf, v_app_down, cmd_down, v_start, v_len);

						error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd_down,v_len+v_start, Readbuf, 5003, Common.CMD_MAX_TIME * 3, 1);
						if((error > 100) || ((Readbuf[1]&0xFF) == 0x7F))//异常
						{
							break;
						}
						Sleep(5);
						m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
						v_app_down += v_len;
						showTip("下载数据:" + v_applength + "\\" +  v_app_down);
					}
					v_down_block ++;
				}
				else if(i == 16)
				{
					cmd[13] = (byte) ((v_calc >> 8) & 0xFF);
					cmd[14] = (byte) (v_calc & 0xFF);
				}
				else if(i == 19)
				{
					cmd[5] = (byte) ((v_calc >> 8) & 0xFF);
					cmd[6] = (byte) (v_calc & 0xFF);
				}

				//特殊处理多次发送命令
				if(i == 14)
				{

				}
				else if(i == 1 || i == 2 || i == 3 || i == 23 || i == 24 || i == 25)
				{
					error = m_com.CanSendOneOnly(0x7DF, cmd, cmdlen);
					Sleep(Common.WAIT_TIME);
					continue;
				}
				else //普通发送命令
				{
					error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmdlen, Readbuf, 5003, Common.CMD_MAX_TIME * 2, 3);
					Sleep(50);
					m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
				}
				Sleep(Common.WAIT_TIME);
				//错误处理
				if(error == 5001) //通讯超时
				{
					if(i > 8)
					{
						showProcessList("通讯超时!",Common.NULL,Common.NG);
						break;
					}
					else
						continue;
				}
				else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					if(i > 8)
					{
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
						return;
					}
					else
						continue;
				}
				else if(error < 100) //异常回复
				{
					if((Readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
						break;
					}
				}
				//特殊处理返回结果
				if(i == 28 || i == 29 || i == 30)
				{
					byte [] v_soft = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf, 4, v_soft, 0, Readbuf[0] - 3);
					String v_softver = new String(v_soft);
					showProcessList(v_softver,Common.NULL,Common.OK);
					if(t_print == null)
						t_print = new ArrayList<String>();
					t_print.add(step_name + ": " + v_softver);
				}
				else if(Readbuf[1] == 0x62) //读数据
				{
					byte [] v_data = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf, 4, v_data, 0, Readbuf[0] - 3);
					String v_show = "";
					String v_get = "";
					int v_code = (Readbuf[2]&0xFF) * 0x100 + (Readbuf[3]&0xFF);
					switch(v_code)
					{
						case 0xF190:
							v_show = new String(v_data);
							v_get = new String(cartype.vin);
							break;
						case 0xF187:
							v_show = new String(v_data);
							v_show = v_show.replace(" ", "");
							v_show = v_show.trim();
							v_get = "";
							break;
						case 0xF18A:
							v_show = new String(v_data);
							v_get = "";
							break;
					}
					v_show = v_show.replace(" ", "");
					v_show = v_show.trim();
					if(v_get.length() > 0)
					{
						showProcessList(v_show,v_get,Common.OK);
					}
					else
					{
						showProcessList(v_show,Common.NULL,Common.NULL);
					}
				}
				else if(i == 9) //结束下载driver
				{
					//showProcessList("",Common.NG);
				}
				else if(i == 15) //结束下载app
				{
					//showProcessList("",Common.NG);
				}
				else if(Readbuf[1] == 0x54) //清故障码
				{
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x59) //读故障码
				{
					//处理故障码
					byte [] dtc = new byte[256];
					dtc[0] = (byte) (((Readbuf[0]&0xFF) - 3) / 4);
					System.arraycopy(Readbuf, 4, dtc, 1, Readbuf[0] - 3);
					ArrayList<Map<String,String>> dtclist = new ArrayList<Map<String,String>>();
					showProcessList("无故障",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x67 && Readbuf[2] == 0x03) //seed
				{
					System.arraycopy(Readbuf, 3, seed, 0, Readbuf[0] - 2);
				}
				else if(Readbuf[1] == 0x74)
				{
					v_maxlen = (Readbuf[3]& 0xFF) * 0x100 + (Readbuf[4]& 0xFF);
				}
				else if(Readbuf[1] == 0x51)
				{
					Sleep(1000);
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x71 && Readbuf[2] == 0x03 && Readbuf[4] == 0x00)
				{
					if(Readbuf[5] == 0x03)
					{
						i --;
						Sleep(1000);
					}
					else if(Readbuf[5] == 0x02)
					{
						showProcessList("",Common.NULL,Common.OK);
					}
					else
					{
						showProcessList("" + (Readbuf[5] & 0xFF),Common.NULL,Common.NG);
						break;
					}
				}
				else if(Readbuf[1] == 0x71 && Readbuf[2] == 0x01)
				{
					showProcessList( "",Common.NULL,Common.OK);
					Sleep(1000);
				}
				else if(Readbuf[1] == 0x51)
				{
					showProcessList("",Common.NULL,Common.OK);
					Sleep(1000);
				}
				else
				{
					showProcessList("",Common.NULL,Common.OK);
				}
			}
		}
	}
	//1.5T 6DCT flash
	private void fun_JX65_TcuFlash2(Section Pstep,String Pname)
	{
		int num = Integer.valueOf(Pstep.get("NUM"));
		int Pid = Integer.valueOf(Pstep.get("MODULE_ID"));
		//int Pid = vPid;
		String Pmodule = Pstep.get("MODULE");
		String step_t = null;
		String step_name = null;
		byte [] Readbuf = new byte[512];
		byte [] seed = new byte[4];
		byte [] key = new byte[4];
		int v_maxlen = 0;
		short [] v_crc = new short[3];
		v_crc[0] = (short) 0xFFFF;
		v_crc[1] = (short) 0xFFFF;
		int [] canid = new int[2];
		if (Common.Communication==0) {
			if(!SetCanInitial(Pmodule,canid)) {
				showProcessList("设置通讯盒",Common.NULL, Common.NG);
				return;
			}
			SetCanInitTimer(0);
			SetCanMode(1,500000);
		}else {
			if(!m_com.SetCanBaud(500000))
			{
				showProcessList("设置波特率",Common.NULL,Common.NG);
				return;
			}
			if(!m_com.SetCanMode(2))
			{
				showProcessList("设置CanMode",Common.NULL,Common.NG);
				return;
			}
			if(!m_com.SetCommunTimer(5, 1000, 5000, 0))
			{
				showProcessList("设置时序",Common.NULL,Common.NG);
				return;
			}
		}

		Can can = cartype.getCan(Pmodule);
		canid[0] = can.getSendid();
		canid[1] = can.getRecvid();
		//String tcu_name = Pstep.get("TCU_NAME");
		String tcu_name = cartype.tcufile;
		if(tcu_name == null)
		{
			showProcessList("Mes推送数据为空",Common.NULL,Common.NG);
			return;
		}
		String v_partnumber = "";
		//SetCanInitTimer(0);
		//先解析刷写数据
		String v_app_file = "";
		String v_dri_file = "";
		byte [] appbuf = null;
		//int v_applen = 0;
		byte [] dribuf = null;
		//int v_drilen = 0;
		byte [] v_dri_adr = new byte[256];
		byte [] v_dri_len = new byte[4];
		int [] v_dri_block = new int[10];
		int v_drilength = 0;
		byte [] v_app_adr = new byte[512];
		byte [] v_app_len = new byte[4];
		int [] v_app_block = new int[100];
		int v_applength = 0;
		int v_down_block = 0; //已经下载的块数
		int v_down_length = 0;
		int v_app_down = 0;
		int v_app_startadr = 0; //
		//driver
		int v_dri_down_block = 0;
		int v_dri_down_length = 0;
		int v_dri_down = 0;
		byte [] cmd_link = {0x02,0x3e,(byte) 0x80};
		int error = 0;
		for(int i = 1; i < (num + 1); i ++)
		{
			stepId = Pid + i;
			step_t = Pstep.get("T" + i);
			stepName = Pstep.get("T" + i + "_NAME");
			if(step_t == null) break;
			if(step_t.length() < 3) continue;
			if(step_t.substring(0, 3).equals("CMD"))  //cmd
			{
				//获取cmd长度
				int cmdlen = Commonfunc.hexStringtoInt(step_t.substring(4, 6)) + 1;
				byte [] cmd = new byte[cmdlen];
				if(Commonfunc.CmdStringToBytes(step_t.substring(4), cmd, cmdlen) != cmd.length) return;
				showTip(step_name + "...");
				//---------------------发送前处理---------------------
				//解析下载文件
				if(i == 7)
				{
					//先解析driver文件
					showTip("解析Driver文件...");
					if(tcu_name == null)
					{
						showProcessList("Mes推送数据为空",Common.NULL,Common.NG);
						return;
					}
					String v_drivername =  "drive.bin";
					v_dri_file = Common.FLASH+  "TCU/" + tcu_name + "/"+ v_drivername;
					showProcessList("驱动文件:" + v_dri_file,Common.NULL,Common.OK);
					if((v_drivername != null) && (v_drivername.length() > 5))
					{
						if(".bin".equals(v_drivername.substring(v_drivername.length() - 4)) )
						{
							try {
								v_drilength = Commonfunc.GetBinFileLength(v_dri_file);
								v_dri_adr[0] = (byte) 0xFF;
								v_dri_adr[1] = (byte) 0xF8;
								v_dri_adr[2] = 0x30;
								v_dri_adr[3] = 0x00;
								v_dri_adr[4] = 0x00;
								v_dri_adr[5] = 0x00;
								v_dri_adr[6] = 0x00;
								v_dri_adr[7] = 0x10;
								v_dri_block[0] = 1;
							} catch (IOException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
								v_drilength = 0;
								m_com.m_log.PrintLog("Open File Fialed:" + v_dri_file);
								showProcessList("打开Driver文件:" + v_drivername,Common.NULL,Common.NG);
								break;
							}
							//
							dribuf = new byte[v_drilength + 10];
							if(".bin".equals(v_drivername.substring(v_drivername.length() - 4)))
								try {
									v_drilength = Commonfunc.ReadBinFile(v_dri_file, dribuf);
								} catch (IOException e) {
									// TODO Auto-generated catch block
									e.printStackTrace();
									v_drilength = 0;
									showProcessList("解析Driver文件" + v_drivername,Common.NULL,Common.NG);
									break;
								}

							if(v_drilength <= 10)
							{
								showProcessList("Driver数据解析:" + v_drivername,Common.NULL,Common.NG);
								break;
							}
						}
					}
					showTip("解析app文件...");

					String v_appname ="01.00.01.bin";
					v_app_file = Common.FLASH+  "TCU/" + tcu_name + "/" +  v_appname;
					showProcessList("flash文件:" + v_app_file,Common.NULL,Common.OK);
					if((v_appname != null) && (v_appname.length() > 5))
					{
						if(".bin".equals(v_appname.substring(v_appname.length() - 4)) || ".BIN".equals(v_appname.substring(v_appname.length() - 4)))
						{
							try {
								v_applength = Commonfunc.GetBinFileLength(v_app_file);
								//v_applength -= 0x30;
							} catch (IOException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
								v_applength = 0;
								m_com.m_log.PrintLog("Open File Fialed:" + v_app_file);
								showProcessList("打开app文件:"+ v_app_file,Common.NULL,Common.NG);
								break;
							}
						}
						//
						appbuf = new byte[v_applength + 10];
						v_applength = 0;
						if(".bin".equals(v_appname.substring(v_appname.length() - 4)) || ".BIN".equals(v_appname.substring(v_appname.length() - 4)))
						{
							try {
								v_applength = Commonfunc.ReadBinFile(v_app_file, appbuf);
								//v_applength -= 0x30;
								v_app_adr[0] = appbuf[7]; //块数
								//System.arraycopy(appbuf, 16, v_app_adr, 1, 4);
								//System.arraycopy(appbuf, 32, v_app_adr, 5, 4);
								v_app_block[0] = ((appbuf[16 + 12]&0xFF) << 24) + ((appbuf[16 + 13]&0xFF) << 16) + ((appbuf[16 + 14]&0xFF) << 8) + (appbuf[16 + 15]&0xFF) ;
								v_app_block[1] = ((appbuf[32 + 12]&0xFF) << 24) + ((appbuf[32 + 13]&0xFF) << 16) + ((appbuf[32 + 14]&0xFF) << 8) + (appbuf[32 + 15]&0xFF) ;
								//crc
								int v_start = 0x30 + 0x200;
								v_crc[0] = Commonfunc.me1781_CalcCRC16(appbuf, v_start, v_app_block[0], (short) 0xFFFF);
								v_start += 0x200000;
								v_crc[1] = Commonfunc.me1781_CalcCRC16(appbuf, v_start, v_app_block[1], (short) 0xFFFF);
								v_crc[2] = Commonfunc.me1781_CalcCRC16(appbuf, v_start, v_app_block[1],v_crc[0]);
							} catch (IOException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
								showProcessList("解析app文件:" + v_appname,Common.NULL,Common.NG);
								break;
							}
						}
						if(v_applength < 100)
						{
							showProcessList("App数据解析失败",Common.NULL,Common.NG);
							break;
						}
					}
				}
				else if(cmd[1] == 0x27 && cmd[2] == 0x04) //安全认证
				{
					if((seed[0] | seed[1]) == 0) continue;
					//EolFunction.Changan_SafeCode_level(seed,key,0x61E47D07);
					Security.Chery_Standard_Safekey(seed, key);
					System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
				}
				else if(i == 9) //开始下载驱动
				{
					if(v_drilength < 10) //无需下载驱动
					{
						i += 2;
						continue;
					}
					else //下载驱动
					{
						if(v_dri_down_block < v_dri_block[0])
						{
							System.arraycopy(v_dri_adr, 1 + 4 * v_dri_down_block, cmd, 4, 4);
							v_dri_down_length =( (v_dri_adr[4]&0xFF) << 24) + ( (v_dri_adr[5]&0xFF) << 16)+ ( (v_dri_adr[6]&0xFF) << 8) + (v_dri_adr[7]&0xFF) ;
							System.arraycopy(v_dri_adr, 0, cmd,4, 8);
						}
					}
				}
				else if(i == 10) //下载驱动
				{
					byte [] cmd_down = new byte[v_maxlen + 2];
					int v_len = 0;
					int v_start = 0;
					int v_frame = 1;
					while(v_dri_down < v_dri_down_length)
					{
						if((v_dri_down + v_maxlen - 2) >= v_dri_down_length) //last
						{
							v_len = v_dri_down_length - v_dri_down;
						}
						else
						{
							v_len = v_maxlen - 2;
						}
						if((v_len + 2) >= 0x100)
						{
							v_start = 1;
							cmd_down[0] = (byte) ((v_len + 2) / 0x100);
						}
						else
							v_start = 0;
						//拷贝数据
						cmd_down[v_start ++] = (byte) ((v_len + 2) % 0x100);
						cmd_down[v_start ++] = 0x36;
						cmd_down[v_start ++] = (byte)(v_frame ++);
						System.arraycopy(dribuf, v_dri_down, cmd_down, v_start, v_len);

						error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd_down,v_len+v_start, Readbuf, 5003, Common.CMD_MAX_TIME * 3, 1);
						if((error > 100) || ((Readbuf[1]&0xFF) == 0x7F))//异常
						{
							break;
						}
						Sleep(5);
						m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
						v_dri_down += v_len;
						showTip("下载数据:" + v_drilength + "\\" +  v_dri_down);
					}
					v_dri_down_block ++;
				}
				else if(i == 12) //擦除APP,按多个块处理
				{
					if(v_down_block < (v_app_adr[0]&0xFF) )
					{
						System.arraycopy(appbuf, 16 + 16 * v_down_block, cmd, 5, 8);
					}
					else
						break;
				}
				else if(i == 15) //请求下载APP
				{
					if(v_down_block <  (v_app_adr[0]&0xFF)  )
					{
						System.arraycopy(appbuf, 24 + 16 * v_down_block, cmd, 4, 8);
						if(v_down_block == 0)
							v_app_startadr = 0x30 + 0x200;
						else if(v_down_block == 1)
							v_app_startadr = 0x30 + 0x200 + 0x200000;
					}
					else
						break;
					v_app_down = 0;

					v_down_length = ( (appbuf[16 + v_down_block * 16 + 12]&0xFF) << 24) + ( (appbuf[16 + v_down_block * 16 + 13]&0xFF) << 16)+ ( (appbuf[16 + v_down_block * 16 + 14]&0xFF) << 8) + (appbuf[16 + v_down_block * 16 + 15]&0xFF) ;;
				}
				else if(i == 16) //下载数据
				{
					byte [] cmd_down = new byte[v_maxlen + 2];
					int v_len = 0;
					int v_start = 0;
					int v_frame = 1;
					while(v_app_down < v_down_length)
					{
						if((v_app_down + v_maxlen - 2) >= v_down_length) //last
						{
							v_len = v_down_length - v_app_down;
						}
						else
						{
							v_len = v_maxlen - 2;
						}
						if((v_len + 2) >= 0x100)
						{
							v_start = 1;
							cmd_down[0] = (byte) ((v_len + 2) / 0x100);
						}
						else
							v_start = 0;
						//拷贝数据
						cmd_down[v_start ++] = (byte) ((v_len + 2) % 0x100);
						cmd_down[v_start ++] = 0x36;
						cmd_down[v_start ++] = (byte)(v_frame ++);
						System.arraycopy(appbuf, v_app_startadr + v_app_down, cmd_down, v_start, v_len);

						error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd_down,v_len+v_start, Readbuf, 5003, Common.CMD_MAX_TIME * 3, 1);
						if((error > 100) || ((Readbuf[1]&0xFF) == 0x7F))//异常
						{
							break;
						}
						Sleep(5);
						m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
						v_app_down += v_len;
						showTip("下载数据进度:" + (v_app_down * 100 / v_down_length) + " %" );
					}
					v_down_block ++;
				}
				else if(i == 18) //检查有效性
				{
					//System.arraycopy(v_dri_adr, 1, cmd, 5, 4);
					if(v_down_block < (v_app_adr[0]&0xFF) )
					{
						System.arraycopy(appbuf, 24 + 16 * v_down_block, cmd, 5, 8);
						if(v_down_block == 0)
						{
							cmd[13] = (byte) ((v_crc[0] >> 8) & 0xFF);
							cmd[14] = (byte) (v_crc[0] & 0xFF);
						}
						else if(v_down_block == 1)
						{
							cmd[13] = (byte) ((v_crc[1] >> 8) & 0xFF);
							cmd[14] = (byte) (v_crc[1] & 0xFF);
						}
					}
					else
						break;
				}
				else if(i == 21) //检查有效性2
				{
					//System.arraycopy(v_dri_adr, 1, cmd, 5, 4);
					cmd[5] = (byte) ((v_crc[2] >> 8) & 0xFF);
					cmd[6] = (byte) (v_crc[2] & 0xFF);
				}
				//特殊处理多次发送命令
				if(i == 10 || i == 16)
				{

				}
				else if(i == 3 || i == 4 || i == 5 || i == 25 || i == 26 || i == 27)
				{
					error = m_com.CanSendOneOnly(0x7DF, cmd, cmdlen);
					Sleep(Common.WAIT_TIME);
					continue;
				}
				else //普通发送命令
				{
					error = m_com.CanOne2OneUDS(canid[0], canid[1], cmd,cmdlen, Readbuf, 5003, Common.CMD_MAX_TIME * 2, 3);
					Sleep(50);
					m_com.CanSendOneOnly(0x7DF, cmd_link, cmd_link[0] + 1);
				}
				Sleep(Common.WAIT_TIME);
				//错误处理
				if(error == 5001) //通讯超时
				{
					if(i > 5)
					{
						showProcessList("通讯超时!",Common.NULL,Common.NG);
						break;
					}
					else
						continue;
				}
				else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					if(i > 8)
					{
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
						return;
					}
					else
						continue;
				}
				else if(error < 100) //异常回复
				{
					if((Readbuf[1]&0xFF) == 0x7F) //异常
					{
						if(i < 5) continue;
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
						break;
					}
				}
				//else
				//	ShowProcessListHide(Pid,step_name,Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.Rok);
				//特殊处理返回结果
				if(i == 28 || i == 29 || i == 30)
				{
					byte [] v_soft = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf, 4, v_soft, 0, Readbuf[0] - 3);
					String v_softver = new String(v_soft);
					showProcessList(v_softver,Common.NULL,Common.OK);
					if(mPrint == null)
						mPrint = new ArrayList<String>();
					mPrint.add(step_name + ": " + v_softver);
				}
				else if(Readbuf[1] == 0x62) //读数据
				{
					byte [] v_data = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf, 4, v_data, 0, Readbuf[0] - 3);
					String v_show = "";
					String v_get = "";
					int v_code = (Readbuf[2]&0xFF) * 0x100 + (Readbuf[3]&0xFF);
					switch(v_code)
					{
						case 0xF195:
						case 0xF193:
						case 0xF191:
							v_show = new String(v_data);
							v_get = "";
							break;
						case 0xF187:
							v_show = new String(v_data);
							v_show = v_show.replace(" ", "");
							v_show = v_show.trim();
							v_partnumber = v_show;
							v_get = "";
							break;
						case 0xF18A:
							v_show = new String(v_data);
							v_get = "";
							break;
					}
					v_show = v_show.replace(" ", "");
					v_show = v_show.trim();
					if(v_get.length() > 0)
					{
						if(v_show.equals(v_get))
							showProcessList(v_show,v_get,Common.OK);
						else
						{
							showProcessList(v_show ,v_get,Common.NG);
							break;
						}
					}
					else
					{
						showProcessList(v_show,Common.NULL,Common.NULL);
					}
				}
				else if(i == 17) //结束下载driver
				{
					if(v_down_block <  (v_app_adr[0]&0xFF) )
					{
						i -= 3;
						continue;
					}
					else
						v_down_block = 0;
					//showProcessList(Pid,step_name,"",Common.Rok);
				}
				else if(i == 22) //结束下载app
				{
					//showProcessList(Pid,step_name,"",Common.Rok);
				}
				else if(Readbuf[1] == 0x54) //清故障码
				{
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x59) //读故障码
				{
					//处理故障码
					byte [] dtc = new byte[256];
					dtc[0] = (byte) (((Readbuf[0]&0xFF) - 3) / 4);
					System.arraycopy(Readbuf, 4, dtc, 1, Readbuf[0] - 3);
					ArrayList<Map<String,String>> dtclist = new ArrayList<Map<String,String>>();
					showProcessList("无故障",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x67 && Readbuf[2] == 0x03) //seed
				{
					System.arraycopy(Readbuf, 3, seed, 0, Readbuf[0] - 2);
				}
				else if(Readbuf[1] == 0x74)
				{
					v_maxlen = (Readbuf[3]& 0xFF) * 0x100 + (Readbuf[4]& 0xFF);
				}
				else if(Readbuf[1] == 0x51)
				{
					Sleep(1000);
					showProcessList( "",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x71 && Readbuf[2] == 0x03)
				{
					if(Readbuf[5] == 0x03)
					{
						i --;
						Sleep(1000);
					}
					else if(Readbuf[5] == 0x02)
					{
						//showProcessList(Pid,step_name,"",Common.Rok);
					}
					else
					{
						showProcessList("" + (Readbuf[5] & 0xFF),Common.NULL,Common.NG);
						break;
					}
				}
				else if(Readbuf[1] == 0x71 && Readbuf[2] == 0x01)
				{
					//showProcessList(Pid,step_name, "",Common.Rok);
					Sleep(1000);
				}
				else if(Readbuf[1] == 0x71 && Readbuf[2] == 0x02  && (Readbuf[3]&0xFF) == 0xFF  && Readbuf[4] == 0x00) //擦除
				{
					//showProcessList(Pid,step_name, "",Common.Rok);
					v_down_block ++;
					if(v_down_block <  (v_app_adr[0]&0xFF) )
					{
						i -= 3;
					}
					else
						v_down_block = 0;
				}
				else if(Readbuf[1] == 0x71 && Readbuf[2] == 0x02  && (Readbuf[3]&0xFF) == 0xFF  && Readbuf[4] == 0x01) //crc
				{
					//showProcessList(Pid,step_name, "",Common.Rok);
					v_down_block ++;
					if(v_down_block <  (v_app_adr[0]&0xFF) )
					{
						i -= 3;
					}
				}
				else if(Readbuf[1] == 0x51)
				{
					showProcessList("",Common.NULL,Common.OK);
					Sleep(1000);
				}
				else
				{
					//showProcessList(Pid,step_name, "",Common.Rok);
				}
			}
		}
	}

	private void fun_kQ5_Stand_module(Section section)
	{
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		int num = Integer.valueOf(section.get("NUM"));
		stepId = Integer.valueOf(section.get("MODULE_ID"));
		int v_req = 0;
		int v_res = 0;
		String step_t = null;
		//String step_name = null;
		String v_module = section.get("MODULE");
		byte [] Readbuf = new byte[512];
		int error = 0;
		int v_len = 0;
		SetCanInitTimer(10);
		//确认模块
		//得到CAN ID
		Can can = cartype.getCan(v_module);
		SetCanMode(can.getMode(),can.getBaud());
		//得到CAN ID
		v_req = cartype.getCan(v_module).getSendid();
		v_res = cartype.getCan(v_module).getRecvid();
		//stepId = Integer.valueOf(section.get("MODULE_ID"));
		for(int i = 1; i < (num + 1); i ++)
		{
			step_t = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(step_t == null) break;
			if(step_t.length() < 3) continue;
			if(step_t.substring(0, 3).equals("CMD"))  //cmd
			{
				//获取cmd长度
				int cmdlen = Commonfunc.hexStringtoInt(step_t.substring(4, 6)) + 1;
				byte [] cmd = new byte[cmdlen];
				if(Commonfunc.CmdStringToBytes(step_t.substring(4), cmd, cmdlen) != cmd.length) return;
				//---------------------发送前处理---------------------
				if(cmd[1] == 0x27 && (cmd[2] == 0x02 || cmd[2] == 0x04))
				{
					if(cmd[0] == 0x06) //4byte
					{
						Security.Chery_KQ5_YaTai_Abs(seed, key);
						System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
					}
					else  //2byte
					{
						Security.Chery_Standard_Safekey(seed, key);
						System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
					}
				}
				else if(cmd[1] == 0x2E)
				{
					int v_code = ((cmd[2]&0xFF) << 8) + (cmd[3]&0xFF);
					switch(v_code)
					{
						case 0xF190:
							System.arraycopy(cartype.vin, 0, cmd, 4, cmd[0] - 3);
							break;
						case 0xD009:
							//if("KQ55EV".equals(cartype.name)) continue;
							System.arraycopy(cartype.byteConfig, 0, cmd, 4, cmd[0] - 3);
							break;
						default:
							break;
					}
				}
				else if(cmd[1] == 0x11)
				{
					if("TBOX1".equals(section.get("MODULE")))
					{
						Sleep(3000);
					}
				}

				//显示
				showTip(stepName + "...");
				//特殊处理多次发送命令
				if(i == -1)
				{
				}
				else //普通发送命令
				{
					error = m_com.CanOne2OneUDS(v_req, v_res, cmd,cmdlen, Readbuf, 5003, Common.CMD_MAX_TIME, 3);
				}
				Commonfunc.sleep(Common.WAIT_TIME);
				//错误处理
				if(error == 5001) //通讯超时
				{
					showProcessList("通讯超时!",Common.NULL,Common.NG);
					break;
				}
				else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((Readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				//特殊处理返回结果
				if(Readbuf[1] == 0x67 && (Readbuf[2] == 0x01 || Readbuf[2] == 0x03))
				{
					System.arraycopy(Readbuf, 3, seed, 0, Readbuf[0] - 2);
				}
				else if(Readbuf[1] == 0x6E)
				{
					int v_code = ((cmd[2]&0xFF) << 8) + (cmd[3]&0xFF);
					byte [] Readdata = new byte[cmd[0] - 3];
					System.arraycopy(cmd,4, Readdata, 0,cmd[0] - 3);
					String v_show = "";
					switch(v_code)
					{
						case 0xF190:
							v_show = new String(Readdata);
							break;
						case 0xD009:
							v_show  = Commonfunc.bytesToHexString(Readdata, 0, Readdata.length);
							break;
						default:
							break;
					}
					showProcessList(v_show,Common.NULL, Common.OK);
				}
				else if(Readbuf[1] == 0x62 && Readbuf[2] == 0x60 && Readbuf[3] == 0x07)
				{
					if(i == 1 || i ==7) //要关钥匙
					{
						/*if((Readbuf[4]&0x08) != 0)
						{
							showTip("关闭钥匙KEY OFF");
							Sleep(1000);
							i --;
						}*/
						handlerSHW("SHW:NO<0>","关闭钥匙KEY OFF",true);
					}
					else if(i > 10)
					{
						/*if((Readbuf[4]&0x08) == 0)
						{
							showTip("打开钥匙KEY ON");
							Sleep(1000);
							i --;
						}*/
						handlerSHW("SHW:NO<0>","打开钥匙KEY ON",true);
					}
				}
				else if(Readbuf[1] == 0x62)
				{
					int v_code = ((Readbuf[2]&0xFF) << 8) + (Readbuf[3]&0xFF);
					byte [] Readdata = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf,4, Readdata, 0,Readbuf[0] - 3);
					String v_show = "";
					String v_get = "";
					switch(v_code)
					{
						case 0xF190:
							v_show = new String(Readdata);
							v_get = new String(cartype.vin);
							break;
						case 0xD009:
							if("KQ55EV".equals(cartype.name)) continue;
							v_show  = Commonfunc.bytesToHexString(Readdata, 0, Readdata.length);
							v_get = Commonfunc.bytesToHexString(cartype.byteConfig, 0, cartype.byteConfig.length);
							break;
						case 0x6000:  //lkey
							v_show = Readdata[0] + "把";
							break;
						case 0xF187:
						case 0xF191:
						case 0xF194:
							v_show = new String(Readdata);
							v_get = "";
							break;
						default:
							break;
					}
					if(v_code == 0xF190) //vin
					{
						if(stepName.indexOf("验证VIN") >= 0)
						{
							if(v_get.equals(v_show))
							{
								showProcessList(v_show,v_get, Common.OK);
								i ++;
							}
						}
						else
						{
							if(v_get.equals(v_show))
								showProcessList(v_show,v_get, Common.OK);
							else
								showProcessList(v_show ,v_get, Common.NG);
						}
					}
					else if(v_code == 0x6000) //readkey
					{
						if(Readdata[0] >= 1)
							showProcessList(v_show,Common.NULL, Common.OK);
						else
							showProcessList(v_show,Common.NULL, Common.NG);
					}
					else if(v_get.length() > 0)
					{
						if(v_get.equals(v_show))
							showProcessList(v_show,v_get, Common.OK);
						else
							showProcessList(v_show ,v_get, Common.NG);
					}
					else
						showProcessList(v_show,Common.NULL, Common.OK);
				}
				else if(Readbuf[1] == 0x54) //清故障码
				{
					showProcessList("",Common.NULL,Common.OK);
					Sleep(500);
				}
				else if(Readbuf[1] == 0x51) //reset
				{
					Sleep(3000);
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x71 && Readbuf[2] == 0x01 && Readbuf[3] == 0x33) //EPS
				{
					if(Readbuf[5] == 0x01)
					{
						showProcessList( "",Common.NULL,Common.OK);
						Sleep(2000);
					}
					else
					{
						showProcessList( "错误代码:" + (Readbuf[5]&0xFF),Common.NULL,Common.NG);
						break;
					}
				}
				else if(Readbuf[1] == 0x71 && Readbuf[2] == 0x03 && Readbuf[3] == 0x33) //EPS
				{
					if(Readbuf[5] == 0x03)
					{
						i --;
						Sleep(1000);
					}
					else if(Readbuf[5] == 0x02) //ok
					{
						showProcessList("",Common.NULL,Common.OK);
					}
					else
					{
						showProcessList("错误代码:" + (Readbuf[5]&0xFF),Common.NULL,Common.NG);
					}
				}
				else if(Readbuf[1] == 0x71 && Readbuf[2] == 0x01 && Readbuf[3] == 0x01) //EPS KQ51EV
				{
					showProcessList( "",Common.NULL,Common.OK);
					Sleep(2000);
				}
				else if(Readbuf[1] == 0x71 && Readbuf[2] == 0x03 && Readbuf[3] == 0x01) //EPS KQ51EV
				{
					if(Readbuf[5] == 0x03)
					{
						i --;
						Sleep(1000);
					}
					else if(Readbuf[5] == 0x00 || Readbuf[5] == 0x01) //ok
					{
						showProcessList("",Common.NULL,Common.OK);
					}
					else
					{
						showProcessList("错误代码:" + (Readbuf[5]&0xFF),Common.NULL,Common.NG);
					}
				}
				else if(Readbuf[1] == 0x71 && Readbuf[2] == 0x01 && Readbuf[3] == 0x61 && Readbuf[4] == 0x40) //key
				{
					String s_gettime = section.get("KEY_TIME");
					int v_time = 10;
					if(s_gettime != null)
						v_time = Integer.valueOf(s_gettime);
					Common.wait = true;
					handlerMessage(Common.DIALOG_WAIT_AUTO_CLOSE, "按遥控钥匙开/闭锁键,学习遥控钥匙...", v_time);
					while(Common.wait){
						//bluetooth.canSendAndRecvN2N(keep, new byte[128], Common.CMD_MAX_TIME);
						m_com.CanSendOneOnly(v_req, keep, keep.length);
						Commonfunc.sleep(1500);
					};

				}
				else if(Readbuf[1] == 0x71)
				{
					if(Readbuf[2] == 0x01)
					{
						Sleep(1000);
						showProcessList("",Common.NULL,Common.OK);
					}
					else if(Readbuf[2] == 0x03)
					{
						if(Readbuf[5] == 0x00)
						{
							Sleep(1000);
							i --;continue;
						}
						else if(Readbuf[5] == 0x01)
						{
							showProcessList("标定成功",Common.NULL,Common.OK);
						}
						else
						{
							showProcessList("标定失败",Common.NULL,Common.NG);
							break;
						}
					}
				}
				else if(Readbuf[1] == 0x59) //读故障码
				{
					byte [] dtc = new byte[512];
					ArrayList<HashMap<String,String>> dtclist = new ArrayList<HashMap<String,String>>();
					if(i == 2){
						dtc[0] = (byte) (((readbuf[2]&0xFF)-0x80-3)/4);
						for(int k = 0; k < dtc[0]; k ++){
							System.arraycopy(readbuf, 7 + k * 3, dtc, 1 + k * 4, 2);
							dtc[1 + k * 4 + 2] = 0;
							dtc[1 + k * 4 + 3] = readbuf[7 + k * 3 + 2];
						}
						dtclist = FileReader.readDtc(module, dtc, 3, false, false);
					}else{

					}
					dtc[0] = (byte) (((readbuf[0]&0xFF) - 3) / 4);
					System.arraycopy(readbuf, 4, dtc, 1, (dtc[0]&0xFF) * 4);
					dtclist = FileReader.readDtc(module, dtc, 3, false, false);

					if(dtclist.size() > 0){
						for(int z = 0; z < dtclist.size(); z ++){
							showProcessList(dtclist.get(z).get(Common.CONTENT),Common.NULL, Common.NG);
							mDtc.add(module.substring(0, module.length() - 1) + "--" + dtclist.get(z).get(Common.CONTENT));
						}
					}else{
						showProcessList("无故障",Common.NULL, Common.OK);
					}
				}
			}
		}
	}
	private void fun_kQ5_IMMO(Section section)
	{
		if(!getpin()){
			showProcessList("未获取到PIN码",Common.NULL,Common.NG);
			return;
		}
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		int num = Integer.valueOf(section.get("NUM"));
		int step_id = Integer.valueOf(section.get("MODULE_ID"));
		int v_req = 0;
		int v_res = 0;
		String step_t = null;
		//String step_name = null;
		String v_module = section.getName();
		byte [] Readbuf = new byte[512];
		int error = 0;
		int v_len = 0;
		int key1_time = 3;
		int key2_time = 3;
		SetCanInitTimer(10);
		//确认模块
		//得到CAN ID
		Can can = cartype.getCan(v_module);
		SetCanMode(can.getMode(),can.getBaud());
		//得到CAN ID
		v_req = cartype.getCan(v_module).getSendid();
		v_res = cartype.getCan(v_module).getRecvid();
		for(int i = 1; i < (num + 1); i ++)
		{
			step_t = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(step_t == null) break;
			if(step_t.length() < 3) continue;
			if(step_t.substring(0, 3).equals("CMD"))  //cmd
			{
				//获取cmd长度
				int cmdlen = Commonfunc.hexStringtoInt(step_t.substring(4, 6)) + 1;
				byte [] cmd = new byte[cmdlen];
				if(Commonfunc.CmdStringToBytes(step_t.substring(4), cmd, cmdlen) != cmd.length) return;
				//---------------------发送前处理---------------------
				if(i == 19)
				{
					handlerSHW("SHW:NO<0>","请更换钥匙2",false);
				}

				if(cmd[1] == 0x27 && (cmd[2] == 0x02 || cmd[2] == 0x04))
				{
					if(cmd[0] == 0x06) //4byte
					{
						Security.chery_ling_safekey(seed, key);
						System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
					}
					else  //2byte
					{
						Security.Chery_Standard_Safekey(seed, key);
						System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
					}
				}
				else if(cmd[1] == 0x2E)
				{
					int v_code = ((cmd[2]&0xFF) << 8) + (cmd[3]&0xFF);
					switch(v_code)
					{
						case 0xF190:
							System.arraycopy(cartype.vin, 0, cmd, 4, cmd[0] - 3);
							break;
						case 0xD009:
							System.arraycopy(cartype.byteConfig, 0, cmd, 4, cmd[0] - 3);
							break;
						case 0x0203:
							System.arraycopy(cartype.pin, 0, cmd, 4, 4);
							System.arraycopy(cartype.pin, 0, cmd, 8, 4);
							System.arraycopy(cartype.pin, 0, cmd, 12, 4);
							System.arraycopy(cartype.pin, 0, cmd, 16, 4);
							break;
						default:
							break;
					}
				}


				//特殊处理多次发送命令
				if(i == -1)
				{
				}
				else //普通发送命令
				{
					error = m_com.CanOne2OneUDS(v_req, v_res, cmd,cmdlen, Readbuf, 5003, Common.CMD_MAX_TIME, 3);
				}
				Commonfunc.sleep(Common.WAIT_TIME);
				//错误处理
				if(error == 5001) //通讯超时
				{
					showProcessList("通讯超时!",Common.NULL,Common.NG);
					break;
				}
				else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((Readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				//特殊处理返回结果
				if(Readbuf[1] == 0x67 && (Readbuf[2] == 0x01 || Readbuf[2] == 0x03))
				{
					System.arraycopy(Readbuf, 3, seed, 0, Readbuf[0] - 2);
				}
				else if(Readbuf[1] == 0x6E)
				{
					int v_code = ((cmd[2]&0xFF) << 8) + (cmd[3]&0xFF);
					byte [] Readdata = new byte[cmd[0] - 3];
					System.arraycopy(cmd,4, Readdata, 0,cmd[0] - 3);
					String v_show = "";
					switch(v_code)
					{
						case 0xF190:
							v_show = new String(Readdata);
							break;
						case 0xD009:
							v_show  = Commonfunc.bytesToHexString(Readdata, 0, Readdata.length);
							break;
						case 0x0203:
							v_show  = Commonfunc.bytesToHexString(Readdata, 0, Readdata.length);
							break;
						default:
							break;
					}
					showProcessList(v_show,Common.NULL, Common.OK);
				}
				else if(Readbuf[1] == 0x62)
				{
					int v_code = ((Readbuf[2]&0xFF) << 8) + (Readbuf[3]&0xFF);
					byte [] Readdata = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf,4, Readdata, 0,Readbuf[0] - 3);
					String v_show = "";
					switch(v_code)
					{
						case 0xF190:
							v_show = new String(Readdata);
							break;
						case 0x0203:
							v_show  = Commonfunc.bytesToHexString(Readdata, 0, Readdata.length);
							break;
						case 0xF10F:
							v_show = "" + Readbuf[4] + "把";
							break;
						default:
							break;
					}
					if(v_code == 0xF10F)
					{
						if(Readbuf[4] == 2)
							showProcessList(v_show,Common.NULL, Common.OK);
						else
							showProcessList(v_show,Common.NULL, Common.NG);
					}
					else
						showProcessList(v_show,Common.NULL, Common.OK);
				}
				else if(Readbuf[1] == 0x54) //清故障码
				{
					showProcessList("",Common.NULL,Common.OK);
					Sleep(500);
				}
				else if(Readbuf[1] == 0x51) //reset
				{
					Sleep(1000);
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x71)
				{
					String v_show = "";
					if(Readbuf[2] == 0x01)
					{
						Sleep(2000);
						showProcessList("",Common.NULL,Common.OK);
					}
					else if(Readbuf[2] == 0x03) // 查询
					{
						if((Readbuf[4] & 0xFF) == 0xF9) //删除钥匙
						{
							if((Readbuf[5] & 0xFF)  == 0) //ok
								showProcessList("",Common.NULL,Common.OK);
							else
								showProcessList("",Common.NULL,Common.NG);
						}
						else if((Readbuf[4] & 0xFF) == 0x01) //检测钥匙
						{
							int isok = 0;
							if((Readbuf[5] & 0xFF)  == 0) //
							{
								v_show = "No Transponder";
								isok = 2;
							}
							else if((Readbuf[5] & 0xFF)  == 1)
							{
								v_show = "Matched Transponder";
								isok = 2;
							}
							else if((Readbuf[5] & 0xFF)  == 2)
							{
								v_show = "Test Success";
								isok = 1;
							}
							else if((Readbuf[5] & 0xFF)  == 3)
							{
								v_show = "Error Transponder";
								isok = 2;
							}
							else if((Readbuf[5] & 0xFF)  == 4)
							{
								v_show = "SK match,IDE not in ECU";
								isok = 1;
							}
							else if((Readbuf[5] & 0xFF)  == 5)
							{
								v_show = "Coil Invalid";
								isok = 2;
							}
							else
							{
								isok = 2;
							}
							if(isok == 2)
							{
								int keytime = 0;
								if(i < 19)  //第一把钥匙
								{
									keytime = key1_time;
									key1_time --;
								}
								else
								{
									keytime = key2_time;
									key2_time --;
								}
								if(keytime > 0) //重试
								{
									showTip("重试第:" + (4 - keytime) + "次...");
									Sleep(1000);
									i -= 2;
								}
								else
								{
									showProcessList(v_show,Common.NULL,Common.NG);
									break;
								}
							}
							else
								showProcessList(v_show,Common.NULL,Common.OK);
						}
						else if((Readbuf[4] & 0xFF) == 0xFA) //学习钥匙
						{
							int isok = 0;
							if((Readbuf[5] & 0xFF)  == 0) //
							{
								v_show = "Learn successful";
								isok = 1;
							}
							else if((Readbuf[5] & 0xFF)  == 1)
							{
								v_show = "IMMO unlock";
								isok = 2;
							}
							else if((Readbuf[5] & 0xFF)  == 2)
							{
								v_show = "Key slot is full";
								isok = 2;
							}
							else if((Readbuf[5] & 0xFF)  == 3)
							{
								v_show = "Transponder Authentication Error";
								isok = 2;
							}
							else if((Readbuf[5] & 0xFF)  == 4)
							{
								v_show = "ABIC or Key Communtcation Timeout";
								isok = 2;
							}
							else if((Readbuf[5] & 0xFF)  == 5)
							{
								v_show = "No Key";
								isok = 2;
							}
							else if((Readbuf[5] & 0xFF)  == 6)
							{
								v_show = "Read Write EEPROM Error";
								isok = 2;
							}
							else if((Readbuf[5] & 0xFF)  == 0x0A)
							{
								v_show = "Learned Key";
								isok = 1;
							}
							else if((Readbuf[5] & 0xFF)  == 0x10)
							{
								v_show = "SK全为0,不能添加钥匙";
								isok = 2;
							}
							else if((Readbuf[5] & 0xFF)  == 0x12)
							{
								v_show = "Write Transponder EEPROM Error";
								isok = 2;
							}
							else if((Readbuf[5] & 0xFF)  == 0x13)
							{
								v_show = "End of Add Key,Crypto Authentication Fail";
								isok = 2;
							}
							else if((Readbuf[5] & 0xFF)  == 0x14)
							{
								v_show = "Transponder CFG page configuration Error";
								isok = 2;
							}
							else if((Readbuf[5] & 0xFF)  == 0x15)
							{
								v_show = "Write RKE SYNC page failure";
								isok = 2;
							}
							else
							{
								isok = 2;
							}
							if(isok == 2)
							{
								int keytime = 0;
								if(i < 19)  //第一把钥匙
								{
									keytime = key1_time;
									key1_time --;
								}
								else
								{
									keytime = key2_time;
									key2_time --;
								}
								if(keytime > 0) //重试
								{
									showTip("重试第:" + (4 - keytime) + "次...");
									Sleep(1000);
									i -= 2;
								}
								else
								{
									showProcessList(v_show,Common.NULL,Common.NG);
									break;
								}
							}
							else
								showProcessList(v_show,Common.NULL,Common.OK);
						}
					}
				}
				else if(Readbuf[1] == 0x59) //读故障码
				{
					byte [] dtc = new byte[512];
					ArrayList<HashMap<String,String>> dtclist = new ArrayList<HashMap<String,String>>();
					if(i == 2){
						dtc[0] = (byte) (((readbuf[2]&0xFF)-0x80-3)/4);
						for(int k = 0; k < dtc[0]; k ++){
							System.arraycopy(readbuf, 7 + k * 3, dtc, 1 + k * 4, 2);
							dtc[1 + k * 4 + 2] = 0;
							dtc[1 + k * 4 + 3] = readbuf[7 + k * 3 + 2];
						}
						dtclist = FileReader.readDtc(module, dtc, 3, false, false);
					}else{

					}
					dtc[0] = (byte) (((readbuf[0]&0xFF) - 3) / 4);
					System.arraycopy(readbuf, 4, dtc, 1, (dtc[0]&0xFF) * 4);
					dtclist = FileReader.readDtc(module, dtc, 3, false, false);

					if(dtclist.size() > 0){
						for(int z = 0; z < dtclist.size(); z ++){
							showProcessList(dtclist.get(z).get(Common.CONTENT),Common.NULL, Common.NG);
							mDtc.add(module.substring(0, module.length() - 1) + "--" + dtclist.get(z).get(Common.CONTENT));
						}
					}else{
						showProcessList("无故障",Common.NULL, Common.OK);
					}
				}
			}
		}
	}
	private void fun_kQ5_ABS(Section section)
	{
		if(!SetCanInitial(section.get("MODULE"),canid)) {
			showProcessList("设置通讯盒",Common.NULL, Common.NG);
			return;
		}
		int num = Integer.valueOf(section.get("NUM"));
		stepId = Integer.valueOf(section.get("MODULE_ID"));
		int v_req = 0;
		int v_res = 0;
		String step_t = null;
		//String step_name = null;
		String v_module = section.get("MODULE");
		byte [] Readbuf = new byte[512];
		int error = 0;
		int v_len = 0;
		SetCanInitTimer(10);
		int seed_len = 0;
		byte v_fillcode = 0;
		//确认模块
		//得到CAN ID
		Can can = cartype.getCan(v_module);
		if(can == null) return;
		SetCanMode(can.getMode(),can.getBaud());
		//得到CAN ID
		v_req = cartype.getCan(v_module).getSendid();
		v_res = cartype.getCan(v_module).getRecvid();
		for(int i = 1; i < (num + 1); i ++)
		{
			step_t = section.get("T" + i);
			stepName = section.get("T" + i + "_NAME");
			if(step_t == null) break;
			if(step_t.length() < 3) continue;
			if(step_t.substring(0, 3).equals("CMD"))  //cmd
			{
				//获取cmd长度
				int cmdlen = Commonfunc.hexStringtoInt(step_t.substring(4, 6)) + 1;
				byte [] cmd = new byte[cmdlen];
				if(Commonfunc.CmdStringToBytes(step_t.substring(4), cmd, cmdlen) != cmd.length) return;
				//---------------------发送前处理---------------------
				if(cmd[1] == 0x27 && (cmd[2] == 0x02 || cmd[2] == 0x04))
				{
					if(seed_len == 4) //4byte
					{
						cmd[0] = 0x06;
						cmdlen = 7;
						Security.Chery_KQ5_YaTai_Abs(seed, key);
						System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
					}
					else  //2byte
					{
						cmd[0] = 0x04;
						cmdlen = 5;
						Security.Chery_Standard_Safekey(seed, key);
						System.arraycopy(key, 0, cmd, 3, cmd[0] - 2);
					}
				}
				else if(cmd[1] == 0x2E)
				{
					int v_code = ((cmd[2]&0xFF) << 8) + (cmd[3]&0xFF);
					switch(v_code)
					{
						case 0xF190:
							System.arraycopy(cartype.vin, 0, cmd, 4, cmd[0] - 3);
							break;
						case 0xD009:
							System.arraycopy(cartype.byteConfig, 0, cmd, 4, cmd[0] - 3);
							break;
						case 0xFD03:  //写加注字节
							cmd[4] = v_fillcode;
							break;
						default:
							break;
					}
				}


				//特殊处理多次发送命令
				if(i == -1)
				{
				}
				else //普通发送命令
				{
					error = m_com.CanOne2OneUDS(v_req, v_res, cmd,cmdlen, Readbuf, 5003, Common.CMD_MAX_TIME, 3);
				}
				Commonfunc.sleep(Common.WAIT_TIME);
				//错误处理
				if(error == 5001) //通讯超时
				{
					showProcessList("通讯超时!",Common.NULL,Common.NG);
					break;
				}
				else if(error == 5002) //点击了返回
				{
					return;
				}
				else if(error > 5000)//其他负响应
				{
					showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
					continue;
				}
				else if(error < 100) //异常回复
				{
					if((Readbuf[1]&0xFF) == 0x7F) //异常
					{
						showProcessList(Commonfunc.bytesToHexString(Readbuf, 0,Readbuf[0]+1),Common.NULL,Common.NG);
						continue;
					}
				}
				//特殊处理返回结果
				if(Readbuf[1] == 0x67 && (Readbuf[2] == 0x01 || Readbuf[2] == 0x03))
				{
					seed_len = Readbuf[0] - 2;
					System.arraycopy(Readbuf, 3, seed, 0, Readbuf[0] - 2);
				}
				else if(Readbuf[1] == 0x6E)
				{
					int v_code = ((cmd[2]&0xFF) << 8) + (cmd[3]&0xFF);
					byte [] Readdata = new byte[cmd[0] - 3];
					System.arraycopy(cmd,4, Readdata, 0,cmd[0] - 3);
					String v_show = "";
					switch(v_code)
					{
						case 0xF190:
							v_show = new String(Readdata);
							break;
						case 0xFD03:
							v_show  = Commonfunc.bytesToHexString(Readdata, 0, Readdata.length);
							break;
						default:
							break;
					}
					showProcessList(v_show,Common.NULL, Common.OK);
				}
				else if(Readbuf[1] == 0x62)
				{
					int v_code = ((Readbuf[2]&0xFF) << 8) + (Readbuf[3]&0xFF);
					byte [] Readdata = new byte[Readbuf[0] - 3];
					System.arraycopy(Readbuf,4, Readdata, 0,Readbuf[0] - 3);
					String v_show = "";
					switch(v_code)
					{
						case 0xF187:
							v_show = new String(Readdata);
							break;
						case 0xD009:
							v_show  = Commonfunc.bytesToHexString(Readdata, 0, Readdata.length);
							break;
						case 0xFD02: //
							break;
						default:
							break;
					}
					showProcessList(v_show,Common.NULL, Common.OK);
				}
				else if(Readbuf[1] == 0x54) //清故障码
				{
					showProcessList("",Common.NULL,Common.OK);
					Sleep(500);
				}
				else if(Readbuf[1] == 0x51) //reset
				{
					Sleep(1000);
					showProcessList("",Common.NULL,Common.OK);
				}
				else if(Readbuf[1] == 0x71)
				{
					if(Readbuf[2] == 0x01)
					{
						Sleep(2000);
						showProcessList("",Common.NULL,Common.OK);
					}
					else if(Readbuf[2] == 0x03)
					{
						if(Readbuf[5] == 0x02)
						{
							Sleep(1000);
							i --;continue;
						}
						else if(Readbuf[5] == 0x01)
						{
							showProcessList("加注成功",Common.NULL,Common.OK);
							v_fillcode = (byte) 0xAA;
						}
						else
						{
							showProcessList("加注失败",Common.NULL,Common.NG);
							v_fillcode = (byte) 0xEE;
							//break;
						}
					}
				}
				else if(Readbuf[1] == 0x59) //读故障码
				{
					byte [] dtc = new byte[512];
					ArrayList<HashMap<String,String>> dtclist = new ArrayList<HashMap<String,String>>();
					if(i == 2){
						dtc[0] = (byte) (((readbuf[2]&0xFF)-0x80-3)/4);
						for(int k = 0; k < dtc[0]; k ++){
							System.arraycopy(readbuf, 7 + k * 3, dtc, 1 + k * 4, 2);
							dtc[1 + k * 4 + 2] = 0;
							dtc[1 + k * 4 + 3] = readbuf[7 + k * 3 + 2];
						}
						dtclist = FileReader.readDtc(module, dtc, 3, false, false);
					}else{

					}
					dtc[0] = (byte) (((readbuf[0]&0xFF) - 3) / 4);
					System.arraycopy(readbuf, 4, dtc, 1, (dtc[0]&0xFF) * 4);
					dtclist = FileReader.readDtc(module, dtc, 3, false, false);

					if(dtclist.size() > 0){
						for(int z = 0; z < dtclist.size(); z ++){
							showProcessList(dtclist.get(z).get(Common.CONTENT),Common.NULL, Common.NG);
							mDtc.add(module.substring(0, module.length() - 1) + "--" + dtclist.get(z).get(Common.CONTENT));
						}
					}else{
						showProcessList("无故障",Common.NULL, Common.OK);
					}
				}
			}
		}
	}
	private void Sleep(int i) {
		// TODO Auto-generated method stub
		Commonfunc.sleep(i);
	}

	/**
	 * 获取pin码和PEPS配置码
	 * @return 是否从上位机获取到
	 */

	private boolean getpin(){
		byte [] pinCheck = new byte[cartype.pin.length];
		if(!Arrays.equals(pinCheck, cartype.pin)){//不是0000,PIN码已获取，不需要再获取了
			return true;
		}
		//cartype.pin[0] = 0x45;
		//cartype.pin[1] = (byte) 0x83;
		//cartype.pin[2] = 0x03;
		//cartype.pin[3] = 0x05;
		//return true;
		if(Common.web_enable  == false)
		{
			return getPinAndPepsConfig();
		}
		boolean result_isok=false;
		String queryvin="resultVin="+new String(cartype.vin);
		String querypin = null;
		m_com.m_log.PrintLog("Start Get Pin...");
		for (int i = 0; i < 3; i++) {
			querypin = HttpRequest.sendGet(Common.web_API_SelectPinforVin, queryvin); //查询pin码
			//querypin = "xx 200   PinStr:{\"PIN\":\"45830305\"}";
			System.out.println(querypin);
			if (querypin.indexOf("200") > 0) {
				break;
			}
		}
		if (!querypin.isEmpty()&&querypin.indexOf("200") > 0) {
			try {
				JSONObject jsonObject = new JSONObject(querypin);
				JSONObject result = jsonObject.getJSONObject("data");
				//JSONObject result = new JSONObject("PinStr:{\"PIN\":\"45830305\"}");
				//获取返回的pin码
				m_com.m_log.PrintAppend("PinStr:" + result);
				// TODO
				Commonfunc.stringToBytes(result.getString("PIN"), cartype.pin);
				m_com.m_log.PrintLog("PinCode:" + Commonfunc.bytesToHexStringP(cartype.pin,0,4));
				result_isok=true;
			} catch (JSONException e) {
				System.out.println("----获取pin码异常-----"+e);
				e.printStackTrace();
				result_isok=false;
			}
		}else {
			result_isok=false;
		}
		return result_isok;
	}

	private  boolean getheat(){
		boolean result_isok=false;
		String queryheatforweb = null;
		m_com.m_log.PrintLog("获取温度开始");
		for (int i = 0; i < 3; i++) {
			queryheatforweb = HttpRequest.sendGetWD(Common.web_API_SelectHeat); //查询温度
			System.out.println(queryheatforweb);
			if (queryheatforweb.indexOf("200") > 0) {
				break;
			}
		}
		if (!queryheatforweb.isEmpty()&&queryheatforweb.indexOf("200") > 0) {
			try {

				JSONObject jsonObject = new JSONObject(queryheatforweb);
				JSONObject result = jsonObject.getJSONObject("data");
				//获取返回的温度
				cartype.heat =result.getString("WD").substring(0,4);
				result_isok=true;
				m_com.m_log.PrintLog("获取温度结束");
			} catch (JSONException e) {
				result_isok = false;
				e.printStackTrace();
			}
		}
		return result_isok;
	}
	private boolean getPinAndPepsConfig(){
		byte [] pinCheck = new byte[cartype.pin.length];
		if(!Arrays.equals(pinCheck, cartype.pin)){//不是0000,PIN码已获取，不需要再获取了
			return true;
		}
		String send = new String(cartype.vin);// + "," + cartype.config + ";";
		ServerSocket server = new ServerSocket();
		byte[] result = new byte[32];
		if(server.connectServer(Common.serverIP, Common.serverPort)){
			int len = server.searchPinFromConfig(send, result);
			if(len < 15){
				return false;
			}else{//2:05517018,52F831,20190907;
				String [] vpin = new String(result).split(",");
				Commonfunc.stringToBytes(vpin[0].substring(2), cartype.pin);
				if(vpin[0].length() < 6){
					return false;
				}
				vpin[0] = vpin[0].substring(2);
				Commonfunc.stringToBytes(vpin[0], cartype.peps);
				return true;
			}
		}
		return false;
	}

	/**
	 * 获取pin码
	 * @return 是否从上位机获取到
	 */
	private boolean getPinFromServer(){
		byte [] pinCheck = new byte[cartype.pin.length];
		if(!Arrays.equals(pinCheck, cartype.pin)){//不是0000,PIN码已获取，不需要再获取了
			return true;
		}
		String send = new String(cartype.vin) + ",;";
		ServerSocket server = new ServerSocket();
		byte[] result = new byte[32];
		if(server.connectServer(Common.serverIP, Common.serverPort)){
			int len =  server.searchPinFromConfig(send, result);
			if(len < 10){
				return false;
			}else{//2:05517018,52F831,20190907;
				String [] vpin = new String(result).split(",");
				Commonfunc.stringToBytes(vpin[0].substring(2), cartype.pin);
				return true;
			}
		}
		return false;
	}
	private boolean GetTpmsfromWebservice(){
		byte [] tpmsid = new byte[16];
		if(!Arrays.equals(tpmsid, cartype.tpms)){//不是0000,tpms已经获取，不需要再获取了
			return true;
		}

		boolean result_isok=false;
		String queryvin="resultVin="+new String(cartype.vin);
		String querytpms = null;
		for (int i = 0; i < 3; i++) {
			querytpms = HttpRequest.sendGet(Common.web_GetTPMS, queryvin); //查询tpms胎压信息
			//querytpms = "{\"msg\":\"操作成功\",\"code\":200,\"data\":{\"flId\":\"5325A823\",\"flPressure\":\"278KPa\",\"flTemp\":\"13℃\",\"frId\":\"5325A99B\",\"frPressure\":\"272KPa\",\"frTemp\":\"12℃\",\"rlId\":\"5325A7DC\",\"rlPressure\":\"275KPa\",\"rlTemp\":\"13℃\",\"rrId\":\"5325A991\",\"rrPressure\":\"256KPa\",\"rrTemp\":\"13℃\"}}";
			System.out.println(querytpms);
			if (querytpms.indexOf("200") > 0) {
				break;
			}
		}
		if(querytpms != null)
			m_com.m_log.PrintAppend(querytpms);
		if (!querytpms.isEmpty()&&querytpms.indexOf("200") > 0) {
			try {
				JSONObject jsonObject = new JSONObject(querytpms);
				JSONObject result = jsonObject.getJSONObject("data");
				//获取返回的pin码
				// TODO
				byte [] v_id = new byte[4];
				Commonfunc.StringToBytes(result.getString("flId"), v_id,4);
				System.arraycopy(v_id,0,cartype.tpms,0,4);
				Commonfunc.StringToBytes(result.getString("frId"), v_id,4);
				System.arraycopy(v_id,0,cartype.tpms,4,4);
				Commonfunc.StringToBytes(result.getString("rlId"), v_id,4);
				System.arraycopy(v_id,0,cartype.tpms,8,4);
				Commonfunc.StringToBytes(result.getString("rrId"), v_id,4);
				System.arraycopy(v_id,0,cartype.tpms,12,4);
				m_com.m_log.PrintAppend("flid:" + result.getString("flId") + " " +
						"frId:" + result.getString("frId") + " " +
						"rlId:" + result.getString("rlId") + " " +
						"rrId:" + result.getString("rrId"));
				if(Common.stationPos == 0)
				{
					ecuModule.addcontext("flid:" + result.getString("flId") + " " + result.getString("flPressure") + " " + result.getString("flTemp"));
					ecuModule.addcontext("frid:" + result.getString("frId") + " " + result.getString("frPressure") + " " + result.getString("frTemp"));
					ecuModule.addcontext("rlid:" + result.getString("rlId") + " " + result.getString("rlPressure") + " " + result.getString("rlTemp"));
					ecuModule.addcontext("rrid:" + result.getString("rrId") + " " + result.getString("rrPressure") + " " + result.getString("rrTemp"));
				}
				result_isok=true;
			} catch (JSONException e) {
				System.out.println("----获取tpms异常-----"+e);
				e.printStackTrace();
				result_isok=false;
			}
		}else {
			result_isok=false;
		}

		return result_isok;
	}


}